BAEL-2435 Add a GUI
-Add spring-boot-starter-web to support rest endpoints -Add a rest endpoint to spoof some form of UI to publish a message, as the old main will no longer publish the commands upon start up
This commit is contained in:
parent
e731b95ffb
commit
fe30c44889
|
@ -39,6 +39,11 @@
|
|||
<version>2.1.1.RELEASE</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.baeldung.axon.gui;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.axonframework.commandhandling.gateway.CommandGateway;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.baeldung.axon.coreapi.commands.CreateMessageCommand;
|
||||
import com.baeldung.axon.coreapi.commands.MarkReadMessageCommand;
|
||||
|
||||
@RestController
|
||||
public class MessagesRestEndpoint {
|
||||
|
||||
private final CommandGateway commandGateway;
|
||||
|
||||
public MessagesRestEndpoint(CommandGateway commandGateway) {
|
||||
this.commandGateway = commandGateway;
|
||||
}
|
||||
|
||||
@PostMapping("/hello")
|
||||
public void publishMessages() {
|
||||
final String itemId = UUID.randomUUID().toString();
|
||||
commandGateway.send(new CreateMessageCommand(itemId, "Hello, how is your day? :-)"));
|
||||
commandGateway.send(new MarkReadMessageCommand(itemId));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue