Skip to content

Commit fe30c44

Browse files
committed
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
1 parent e731b95 commit fe30c44

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

axon/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
<version>2.1.1.RELEASE</version>
4040
<scope>compile</scope>
4141
</dependency>
42+
43+
<dependency>
44+
<groupId>org.springframework.boot</groupId>
45+
<artifactId>spring-boot-starter-web</artifactId>
46+
</dependency>
4247
</dependencies>
4348

4449
<properties>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.baeldung.axon.gui;
2+
3+
import java.util.UUID;
4+
5+
import org.axonframework.commandhandling.gateway.CommandGateway;
6+
import org.springframework.web.bind.annotation.PostMapping;
7+
import org.springframework.web.bind.annotation.RestController;
8+
9+
import com.baeldung.axon.coreapi.commands.CreateMessageCommand;
10+
import com.baeldung.axon.coreapi.commands.MarkReadMessageCommand;
11+
12+
@RestController
13+
public class MessagesRestEndpoint {
14+
15+
private final CommandGateway commandGateway;
16+
17+
public MessagesRestEndpoint(CommandGateway commandGateway) {
18+
this.commandGateway = commandGateway;
19+
}
20+
21+
@PostMapping("/hello")
22+
public void publishMessages() {
23+
final String itemId = UUID.randomUUID().toString();
24+
commandGateway.send(new CreateMessageCommand(itemId, "Hello, how is your day? :-)"));
25+
commandGateway.send(new MarkReadMessageCommand(itemId));
26+
}
27+
28+
}

0 commit comments

Comments
 (0)