/
MessageDaoService.java
34 lines (28 loc) · 1.14 KB
/
MessageDaoService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package io.camunda.zeebe.spring.example;
import io.camunda.zeebe.client.ZeebeClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.Duration;
@Component
public class MessageDaoService {
@Autowired
private ZeebeClient zeebe;
public void publishMessage() {
System.out.println("Send in message...");
zeebe.newPublishMessageCommand()
.messageName("messageYes")
.correlationKey("yes")
.messageId("121212")
//.timeToLive(Duration.ofMinutes(1))
//.timeToLive(message.getTimeToLive())
//.variables(message.getVariables())
.send()
.whenComplete((c, t) -> {
System.out.println("...completed");
})
.exceptionally(t -> {
System.out.println("...could NOT be sent: " + t.getMessage());
throw new RuntimeException("Could not hand over record to Zeebe: "+". check nested exception for details: " + t.getMessage());
});
}
}