Skip to content

Latest commit

 

History

History

example-twitter

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Tweet directly from the Tasklist - Spring Boot packaged

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.

Prerequisites

  • Java 17/21

How is it done

  1. 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.21.0</version>
</dependency>
...
  1. 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 the processes.xml file in your META-INF folder:
@SpringBootApplication
@EnableProcessApplication
public class TwitterServletProcessApplication {

  public static void main(String... args) {
    SpringApplication.run(TwitterServletProcessApplication.class, args);
  }
}
  1. You can also put BPMN, CMMN and DMN files in your classpath, they will be automatically deployed and registered within the process application.

  2. You can configure your Spring Boot application using application.yaml file. All possible Camunda-specific configuration parameters are listed here

  3. This example provides two implementations for posting a Tweet:

  • TweetContentOfflineDelegate (default) - will just print the tweet content on console
  • TweetContentDelegate - 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>
...

Run the application and check the result

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.