This example demonstrates how you can use a BPMN process and the Tweeter API to build a simple Twitter client.
It uses camunda-bpm-spring-boot-starter-webapp
and thus embed Tomcat as a web container.
The example contains:
- a process application with one process deployed on the Camunda engine
- custom forms to create and review the Tweet
- creates on startup an admin user "demo" (password: demo)
It also demonstrates the usage of the application.yaml
configuration file.
- Java 17/21
- To embed the Camunda Engine you must add following dependency to your
pom.xml
:
...
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
<version>7.22.0</version>
</dependency>
...
- With Spring Boot you usually create an "application" class annotated with
@SpringBootApplication
. In order to have a Camunda process application registered, you can simply add the annotation@EnableProcessApplication
to the same class and also include theprocesses.xml
file in yourMETA-INF
folder:
@SpringBootApplication
@EnableProcessApplication
public class TwitterServletProcessApplication {
public static void main(String... args) {
SpringApplication.run(TwitterServletProcessApplication.class, args);
}
}
-
You can also put BPMN, CMMN and DMN files in your classpath, they will be automatically deployed and registered within the process application.
-
You can configure your Spring Boot application using
application.yaml
file. All possible Camunda-specific configuration parameters are listed here -
This example provides two implementations for posting a Tweet:
TweetContentOfflineDelegate
(default) - will just print the tweet content on consoleTweetContentDelegate
- can post a tweet when providing credentials for your twitter account
You can switch between two implementations by changing the name of a Spring bean to tweetAdapter
. This tweetAdapter
bean is further referenced in
the BPMN diagram via "Delegate expression" in a service task:
...
<serviceTask id="service_task_publish_on_twitter" name="Publish on Twitter" camunda:delegateExpression="#{tweetAdapter}">
...
</serviceTask>
...
You can build the application by mvn clean install
and then run it with java -jar
command.
Go to http://localhost:8080
(provide login/password from application.yaml
, default: demo/demo) then go to Tasklist and try to start the process and complete the tasks, observe log entries or the real tweet when TweetContentDelegate
is used.