MQTT Service Task, should

I have a BPMN in which I have a MQTT Task(service task), which subscribes to a particular topic/channel and stores the json data which I am getting from the MQTT simulator into a process variable, for every 30 seconds. However I have a script task after the MQTT Task, and since the MQTT Task doesn’t get finished, and keeps listening to the topic/channel the script task never gets executed. In the script task i am trying to access the process variable which I have stored when the mqtt task got executed.

Expected: I want to access process variable in script task once message has been fetched mqtt task and gets stored in a process Variable.

Actual Result: I am not able to access process variable inside script task.

Note: MQTT task which is a service task and its implementation is a JAVA class, and I don’t want to end this task, since i want to keep listening to the topic/channel for messages, but I want the stored process variables to be accessbile to the script task which is next to mqtt task.

Hey @Niall, Can you check this issue please.

@satyaram413 by adding non-interrupting timer boundary event to user task, it will start polling tasks with configured time. They administrator can decide when the instance can be closed by completing the task.

There wouldnt be any user intervention @arvindhrs, i use user task at the end just to show, that i am able to create process variable, the whole process would be an automated one. Mqtt service task recieves data from. Mqtt simulator every 30 seconds and should go to next task after it recieves data, but the problem here is if i unsubscribe the mqttservice class from listening to the topic, then i would have to subscribe to the topic of mqtt, again either using a timer or a user task, since i cannot use user task, i might have to use timer, which is not working, Would there be any chance for me to continue listening to mqtt topic and by not ending that that task going to the script task which i mentioned. Within a process a task should be running all the time and the other tasks should respond to the data which it has fetched. Note: Cannot use user task since this is an automation process.

you can try something like this:

Hi @satyaram413,

I think there is a basic misundertstanding about processes in your approach.

The basic idea about processes is, that each task is taken after the previous is completed. The symbol to express this is the Sequence Flow.

Generally it is not possible to keep a task open (not complete it) and expect the next task (following the sequence flow) to start.

In your case you can either decide to start a process instance to work on the content of the MQTT message once it’s recieved. This can be modeled with with message start event: https://docs.camunda.org/manual/7.12/reference/bpmn20/events/message-events/#message-start-event

Or you can start a process and look in parallel to receive incoming messages with a non interrupting event subprocess: https://docs.camunda.org/manual/7.12/reference/bpmn20/subprocesses/event-subprocess/

To give a more concrete advise, please describe your use case in more details.

Hope this helps, Ingo

1 Like

Yes @Ingo_Richtsmeier you are absolutely correct, Mqtt task will never will be completed, it is always running in the background( just like a thread), it will receive messages and create/replace process variable, but I want to execute the next task probably a script task, but since the mqtt task is not completed, I am not able to execute script task. The script task will be using the process variable which were created by mqtt task. As soon as mqtt task recieves message, it should send to script task.

Can you please advise the sequence flow, I tried, parallel gateway and inclusive gateway, but I was facing the following issue.

[6fa96e03a3cb4f5aa142bf5fd9e4f982] org.camunda.commons.logging.BaseLogger.logError ENGINE-16004 Exception while closing command context: execution f46bbdcd-82e3-11ea-941f-025041000001 doesn't exist: execution is null

Hi @satyaram413,

@Ingo_Richtsmeier is completely right.
My suggestion is to make it simple and go with the 1’st suggested solution by @Ingo_Richtsmeier which I already mentioned it in my below post

Hi @hassang, the simulator hits every 10 seconds, which means Mqtt task will return output every 10 seconds, which means process-instance ids will exponentially increase, which will create performance issue, so I am looking for a message catch and throw event solution, so that whenever my mqtttask has message it throws it out to the script task.

Hi @satyaram413,

If your process is a short running process then I think it would be okay to start many instances.
As many of the already started instances would be terminated before the new ones would be started.

Hi @hassang,

My process would be running for a longer period of time, maybe days and months. Can you show me how to implement MQTT task as a standalone process with a BPMN flow, that would be really helpful.