Receive Data, How-To

It is possible to interact with external systems by using a “serviceTask” with “flowable:class” attribute referencing a “org.flowable.engine.delegate.JavaDelegate” implementation class that do the actual job.

For example:

But, how can the BPMN receive data?

For example, imagine a BPMN process that stops until an external system provide a mandatory information to proceed.

What is the right task to use to wait for these data? “receiveTask”? “intermediateCatchEvent”? other?

And how actually the element receive the data (what is supposed to be used instead of the “JavaDelegate”)?
What is the best practice?
Any useful example?

Thanks

Since no one has answered, I’ll answer with my opinion. I think either a Receive Task or a Message Intermediate Catching Event would be appropriate to model the asynchronous receipt of data from another system. Neither of them use a specific interface like the JavaDelegate, but there are code examples in the documentation on how to use them. I’d set up an endpoint for the remote system to call back to and have that endpoint either trigger the receive task or throw the appropriate message event.

Firstly, thanks for the reply.

By reading the documentation (v6.4.2) the only access point to BPMNs instances seems to be the REST-API (through the “flowable-rest” servlet).

What I’m planning to do, is to implement an adapter (executable jar, servlet, EJB, but this isn’t important at the moment) that receives the messages from other systems on its own interface (SOAP, JMS, …).

This adapter translates the received message to the JSON format {“action”:“messageEventReceived”,“messageName”:,“variables”:[ < … > ]} and locate the executions that waiting for that message by using the"GET runtime/executions" (§16.6.4. “List of executions”) assigning to the “messageEventSubscriptionName” query parameter the value.

If no executions will be found, nothing happens, and the message will be discarded.

On the contrary, if one or more execution will be found, the JSON message will be sent to each of them as the payload of the “PUT runtime/executions/{executionId}” (§16.6.2. “Execute an action on an execution”).

Is this correct? There is a better way, or a best practice, to set up an endpoint for the remote system?

Also, links to specific topic documentation will be appreciated.

Thanks.

Can we back up for a moment and discuss how you’re using Flowable? Will you be using the UI apps (flowable-task, etc) or are you mostly using the APIs?

Personally, I’d use the Java API’s over the REST API if possible, especially since it appears that you are in a primarily Java environment.

Will

Hi Will,

my purpose is to use Flowable via REST-API exposed by flowable-rest.war.

Essentially, each of my BPMN has to:

  • be triggered or started or resumed by some external event, received as a message
  • make simple decisions based on the received message content data, or more complex decisions based on business rules outcomes
  • call other systems (stop/start processes, notify alerts, etc…) accordingly to that decisions

In other words, my BPMNs have to orchestrate other systems by watching what they are doing (“messageEventReceived”), and directly operate them or send notifications, etc. (JavaDelegate implementations).

Lastly you are right: I’m in a primarily Java environment.

Thanks for your kindly reply.