RabbitMQ consumers
Purpose
Processes in Eximee may consist of steps that require asynchronous communication with external systems. Example: we send a request for document verification, but it is time-consuming, so we will have to wait for a response. This task may be performed asynchronously in an external system and it may notify the Eximee process via a RabbitMQ queue. RabbitMQ consumers are used precisely to handle such responses. We use them to receive the message, pre-process the data contained in it, and notify Eximee BPMS to continue process execution.
How it works
The whole flow consists of four elements:
1. Eximee process sends a request to the external system, including the process instance ID,
and stops at the "Message Intermediate Catch Event" step
2. External system performs the work and publishes the response to the RabbitMQ queue,
sending back the process instance ID in it
3. lowcode-queue-consumer receives the message from the queue and runs the consumer script
assigned to that queue
4. Consumer script reads the process instance ID and sends to Eximee BPMS
a message that resumes the processMessage reception is handled by the application lowcode-queue-consumer. The application knows which consumer handles which queue, thanks to the mapping set by the administrator in its configuration. The consumer itself does not contain queue information.
Step 1. Agree on the details with the administrators
Before preparing the process, agree with the administrators on:
queue, from which the consumer is to receive messages. The queue is created on the broker by the RabbitMQ administrator,
DLQ queue, to which messages that the consumer does not process will be sent,
connection name with the broker, in which the administrators will configure the queue, for example
integration. The process designer may suggest a name, and the administrators confirm it or indicate an existing connection. The consumer script does not use this name; the administrators need it for configuration,consumer name, for example
message_consumer_demo. The name is chosen by the process designer, and the administrators enter it in the queue-to-consumer mapping.
Without mapping the queue to a consumer, the consumer does not receive any messages.
Example request
Send the agreed details to the administrators in a request, for example:
The configuration that the administrators prepare based on this is described on the page RabbitMQ consumer configuration.
Step 2. Prepare the process
Add a message wait step
At the point where the process should wait for the response, add a step of type Message Intermediate Catch Event. In the step panel, expand the Message section Name field enter the message name. The name must meet Eximee BPMS requirements (Message Events). The same name will later go into the consumer script.
In the examples on this page, the message name is lowcodeDemoMessage.


Send the process instance ID to the external system
The consumer resumes the process solely based on the process instance ID (processInstanceId). Resumption by business key is not available. So the external system must receive this ID in the request and return it in the response.
In the examples on this page, a message with the process instance ID goes to the queue eximee_demo_integration. Such a message can be sent from a script with Eximee's help; this is described on the page Lowcode to RabbitMQ. Such a message can also be sent by an external system.
Step 3. Agree on the message format
The platform does not impose a message format. Agree it with the external system team before writing the consumer. The message must contain the process instance ID.
Example of the format used later on this page:
The message content is read as text in UTF-8 encoding. If the message is JSON, the script converts it to an object itself using JSON.parse.
Step 4. Create a consumer in Eximee Designer
In Eximee Designer open Library → Consumers.
Click Add Consumer.
Enter the consumer name agreed with the administrators in step 1, for example
message_consumer_demo.Write the consumer script and save it.
The same consumer can handle messages from RabbitMQ and Kafka. Where the messages come from is determined solely by the administrator configuration.
Example consumer script
Consumer script message_consumer_demo receives the message in the format from step 3, validates it, and resumes the process:
After receiving the sample message from step 3, the process with ID 8f0b7a52-0c43-11ef-9a1c-0242ac120002 continues and receives the variable rabbitData = sample value.
Writing rules for the consumer
Resume the process by calling
api.process.v1.byInstanceId(processInstanceId).correlateMessage(nazwaWiadomosci, zmienne). The consumer does not run in the context of any process, so always specify the instance ID explicitly, throughbyInstanceId.Variables passed to
correlateMessagemust have text values. Convert numbers and boolean values to text with the functionString(). The second parameter can be omitted if the process does not need any variables.
Ending the script and the fate of the message
What happens to the message depends solely on how the script ends:
The script ends normally or via return
The message is considered handled and removed from the queue.
The script throws an exception (throw), including an exception from correlateMessage
The message is rejected and sent to the DLQ. If no DLQ is configured, the message is lost.
The platform does not retry processing of a message that the script failed to process. Such a message goes directly to the DLQ.
Message data available in the script
Function context.getMessage() returns the message along with metadata:
value
string
Message content.
headers
object
Message headers. Read a header value with the function headers.get('name').
key
string
Message ID (property message_id). null, if the sender did not set it.
topic
string
Queue name from which the message originates.
timestamp
number
Message creation time in milliseconds since 1970-01-01 (property timestamp). 0, if the sender did not set it.
queue.queue
string
Queue name from which the message originates.
queue.exchange
string
Exchange from which the message was routed to the queue. Empty for the default exchange.
queue.routingKey
string
Routing key with which the message was routed to the queue.
Field event is filled in only for messages from Kafka. In a RabbitMQ message it has the value null, so a script handling both sources will be able to tell from it where the message came from.
Example of reading metadata:
Troubleshooting
The message goes to the DLQ and the process does not continue
The process was not waiting at the wait step, the message name in correlateMessage differs from the name in the process, or the process instance ID is incorrect.
Check the application log lowcode-queue-consumer for this message. Make sure the message name is identical in the process and in the script.
The message disappears and is in no queue
The script ended by return either by catching an error, or no DLQ was configured for the queue.
Raise an exception for messages that cannot be processed, and ask the administrators to configure a DLQ.
After migrating the application to another environment, messages go to the DLQ and the process does not continue
The consumer was not migrated to this environment. The consumer is not part of the application and is not migrated with it.
Move the consumer to this environment separately, in addition to the application.
Change in the consumer script does not work
The consumer was not saved or the cache has a long TTL.
Save the consumer and ask the administrators to clear the cache.
Problems starting the application, connecting to the broker, and queue mapping are described on the page RabbitMQ consumer configuration. There you will also find how to verify the consumer works using a test message.
Related pages
RabbitMQ consumer configuration — application configuration
lowcode-queue-consumer, queues, and DLQ.Lowcode to RabbitMQ — sending messages to a queue from scripts and script tasks.
Kafka consumers — the same mechanism for messages from Kafka.
Operations and access to process data — API
api.process.Script Task API — writing script tasks in a process.
Last updated
Was this helpful?
