Executing Camel task through Flowable Task

Hi all,

I try to run a process definition containing Camel task into the application Flowable Task. As mentioned in issue #1322, Flowable Task does not support Camel tasks.

Because of version compatibility between SpringBoot, Flowable and Camel, it is not possible to add this support in Flowable Task 6.3.1. So, I’m trying to add it to Flowable Task 6.4.0-SNAPSHOT. I have added the following dependencies to the project flowable-ui-task-app, built it and redeployed it in my Tomcat instance:

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring-boot-starter</artifactId>
            <version>2.22.0</version>
        </dependency>
        <dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-camel</artifactId>
        </dependency>

My process definition containing Camel task is the one of the Flowable BPMN user guide. I deployed it successfully.

When I started a process instance, I have got an error about the Camel endpoint flowable://SimpleCamelCallProcess:simpleCall not defined. Normal because the Camel route was not deployed into the BPMN engine.

So I have packaged the Camel route (as a Java class) into a JAR file and put it in flowable-task/WEB-INF/lib directory in my Flowable Tomcat. And I restarted my Tomcat instance.

When I try to start a new process instance, I get the same error: Camel route not found.

Do you know how Camel route must be deployed ?

Thanks for your help,
Regards,
Christophe

When starting Flowable UI Task, I get following log traces:

2018-10-12 12:23:45.476  INFO 31454 --- [io-8080-exec-19] o.a.c.s.b.RoutesCollector                : Loading additional Camel XML routes from: classpath:camel/*.xml
2018-10-12 12:23:45.476  INFO 31454 --- [io-8080-exec-19] o.a.c.s.b.RoutesCollector                : Loading additional Camel XML rests from: classpath:camel-rest/*.xml
2018-10-12 12:23:45.479  INFO 31454 --- [io-8080-exec-19] o.a.c.s.SpringCamelContext               : Apache Camel 2.22.0 (CamelContext: camel-1) is starting
2018-10-12 12:23:45.482  INFO 31454 --- [io-8080-exec-19] o.a.c.m.ManagedManagementStrategy        : JMX is enabled
2018-10-12 12:23:45.664  INFO 31454 --- [io-8080-exec-19] o.a.c.s.SpringCamelContext               : StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
2018-10-12 12:23:45.668  INFO 31454 --- [io-8080-exec-19] o.a.c.s.SpringCamelContext               : Total 0 routes, of which 0 are started
2018-10-12 12:23:45.669  INFO 31454 --- [io-8080-exec-19] o.a.c.s.SpringCamelContext               : Apache Camel 2.22.0 (CamelContext: camel-1) started in 0.190 seconds
2018-10-12 12:23:45.711  INFO 31454 --- [io-8080-exec-19] o.f.u.t.c.Bootstrapper                   : Migrated 0 app deployments
2018-10-12 12:23:45.719  INFO 31454 --- [io-8080-exec-19] o.f.u.t.a.FlowableTaskApplication        : Started FlowableTaskApplication in 16.158 seconds (JVM running for 981.413)

where we can see no route is loaded even if its JAR file was added in WEB-INF/lib

Regards,
Christophe

I haven’t tried it myself yet, but an alternative would be to have the camel route definted in Java and put it on a package that is known (e.g. org.flowable.ui.task.conf). Or is that the way you’ve tried it?

Thanks @joram for your proposal, but same problem: the route is not loaded.

Hi Guys,
Like Christophe I have been trying to get the camel integration working. I have built the Tasks-UI app with the dependencies he has used which seems to make sense.

From what I can gather from reading the documentation on a camel task, I need to register a route using a spring context bean. The documentation says:

From the documentation (link)
"First of all, we need a Spring context that contains the introduction to the routes as mentioned previously. The following serves this purpose: "

<camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
  <packageScan>
    <package>org.flowable.camel.examples.simpleCamelCall</package>
  </packageScan>
</camelContext>

I am new to spring-boot so how do you register this bean. Where do I put this xml in the spring boot task-ui app. I understand I can add an xml context for a bean to a jar but where in a mvn project should I put the xml file. Do I put this xml config in a file called myContext.xml in /src/main/resources of my project, implement the route in a java class in the referenced package and then build the jar to deploy to the Task app?

Any help greatly appreciated.

Brian

Hey Brian,

The easiest way to do this with Spring Boot is to add the Spring Boot Starter from Camel:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-spring-boot-starter</artifactId>
    <version>2.23.0</version>
</dependency>

2.23.0 is the version that Flowable uses, so I would suggest to stick with this one.

You then need to define your routes as Spring @Component that extend from RouteBuilder. The routes need to be next to the FlowableTaskApplication (otherwise they won’t be automatically picked up). See also the Camel Spring Boot documentation.

In case you don’t want to use the Camel Starter (I highly recommend that you do :smile:). You can use the Camel Spring Java Config:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-spring-javaconfig</artifactId>
    <version>2.23.0</version>
</dependency>

Then you will need a Spring @Configuration that would extend from CamelConfiguration and you can will need to configure the routes via that.

Cheers,
Filip

Hey Filip,

Thanks for the reply. A couple of questions on this answer. Which flowable module should the Spring Boot Starter be added to?

What do you mean when you say:

The routes need to be next to the FlowableTaskApplication

How do I make a spring @component class be “next” to the FlowableTaskApplication.

Regards

Brian

Hey Brian,

According to what you said with

I understood that you are building the Task UI app on your own.

What you need to do is to add the camel-spring-boot-starter dependency in the flowable-ui-task-app module. Basically the same module where you put the flowable-camel dependencies.

You will put your component in the same package as the FlowableTaskApplication

Hope this helps,
Filip

Hi Filip,

My thanks once again for your help. I got it up and running and tried out the examples in the Camel module. I wrote a blog on this for anyone who needs to do the same thing. Find it here.

Regards
Brian

Nice blog post Brian.

Regarding:

One thing to note on this. If you set the camel task to be async, then the process may fail if camel responds straight away. From our analysis this is because the Receive Task has not been created yet when camel tries to respond and find the task.

Exactly your analysis is the reason for the Triggerable Service Task. I know that you mentioned it as well, but just wanted to stress it out.