GithubHelp home page GithubHelp logo

omarchenko4j / camunda-bpm-spring-boot-starter-external-task-embedded-client Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 39 KB

Spring Boot Starter provides embedded client to fast handling of external tasks for Camunda BPM.

License: Apache License 2.0

Java 100.00%
java spring-boot camunda-bpm

camunda-bpm-spring-boot-starter-external-task-embedded-client's Introduction

Camunda External Task Embedded Client as Spring Boot Starter


Spring Boot Starter provides embedded client to fast handling of external tasks for Camunda BPM. An embedded client opens up a different way to handle external tasks than camunda-bpm-spring-boot-starter-external-task-client. It works on top of thrown historical events to avoid long polling when using the FetchAndLock API.

Getting Started

Dependency

Maven:

<dependency>
  <groupId>io.github.omarchenko4j</groupId>
  <artifactId>camunda-bpm-spring-boot-starter-external-task-embedded-client</artifactId>
  <version>0.3.0</version>
</dependency>

Gradle:

compile("io.github.omarchenko4j:camunda-bpm-spring-boot-starter-external-task-embedded-client:0.3.0")

Example

  1. We have the following process:

alt text

  1. Implement external task handlers:

2.1 With manually locking and completing an external task:

@Slf4j
@Component
@ExternalTaskTopicName("scoreProvider") // Specifies the topic name of external task.
public class ScoreProviderExternalTaskHandler extends AbstractExternalTaskHandler {
    @Override
    public void handle(ExternalTask externalTask) {
        String externalTaskId = externalTask.getId();
        
        externalTaskService.lock(externalTaskId, "WORKER", TimeUnit.SECONDS.toMillis(5)); // Manual lock.
        
        log.info("Some logic of score provider.");
        
        externalTaskService.complete(externalTaskId, "WORKER"); // Manual complete.
    }
}

2.2 Without manually locking but with manually completing an external task:

@Slf4j
@Component
@ExternalTaskTopicName("loanGranter")
public class LoanGranterExternalTaskHandler extends ExternalTaskLockingHandler {
    public LoanGranterExternalTaskHandler() {
        super("WORKER", TimeUnit.SECONDS.toMillis(5));
    }
    
    @Override
    protected void handleAfterLocking(ExternalTask externalTask) {
        log.info("Some logic of loan granter.");
        
        externalTaskService.complete(externalTask.getId(), workerId); // Manual complete.
    }
}

2.3 Without manually locking and completing an external task:

@Slf4j
@Component
@ExternalTaskTopicName("requestRejecter")
public class RequestRejecterExternalTaskHandler extends ExternalTaskCompletingHandler {
    public RequestRejecterExternalTaskHandler() {
        super("WORKER", TimeUnit.SECONDS.toMillis(5));
    }
    
    @Override
    protected void handleBeforeCompleting(ExternalTask externalTask) {
        log.info("Some logic of request rejecter.");
    }
}
  1. Start a process instance. It works!

License

Camunda External Task Embedded Client is Open Source software released under the Apache 2.0 license.

camunda-bpm-spring-boot-starter-external-task-embedded-client's People

Contributors

omarchenko4j avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.