-
Notifications
You must be signed in to change notification settings - Fork 37
/
TwitterWorker.java
29 lines (24 loc) · 1.16 KB
/
TwitterWorker.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
package org.camunda.community.examples.twitter.process;
import io.camunda.zeebe.spring.client.annotation.JobWorker;
import io.camunda.zeebe.spring.client.annotation.VariablesAsType;
import io.camunda.zeebe.spring.client.exception.ZeebeBpmnError;
import org.camunda.community.examples.twitter.business.DuplicateTweetException;
import org.camunda.community.examples.twitter.business.TwitterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class TwitterWorker {
@Autowired private TwitterService twitterService;
@JobWorker(type = "publish-tweet")
public void handleTweet(@VariablesAsType TwitterProcessVariables variables) throws Exception {
try {
twitterService.tweet(variables.getTweet());
} catch (DuplicateTweetException ex) {
throw new ZeebeBpmnError("duplicateMessage", "Could not post tweet, it is a duplicate.");
}
}
@JobWorker(type = "send-rejection")
public void sendRejection(@VariablesAsType TwitterProcessVariables variables) throws Exception {
// same thing as above, do data transformation and delegate to real business code / service
}
}