For the complete documentation index, see llms.txt. This page is also available as Markdown.

RabbitMQ consumers

Availability of the functionality depends on the license and may not be available in all deployments.

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 process

Message 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.

Illustration 1. Example process with a "Message Intermediate Catch Event" step
Illustration 2. Example configuration of a "Message Intermediate Catch Event" step

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

  1. In Eximee Designer open Library → Consumers.

  2. Click Add Consumer.

  3. Enter the consumer name agreed with the administrators in step 1, for example message_consumer_demo.

  4. 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, through byInstanceId.

  • Variables passed to correlateMessage must have text values. Convert numbers and boolean values to text with the function String(). The second parameter can be omitted if the process does not need any variables.

Consumers have limited access to the API. They can use only the Logger object and the functions api.process.v1.byInstanceId(processInstanceId): correlateMessage, getProcessInfo and getUserTaskInfo. Other functions api.process, for example startProcess and setAccessGroups, are unavailable in the consumer, as are REST calls and message sending. More about the process API: Operations and access to process data

Ending the script and the fate of the message

What happens to the message depends solely on how the script ends:

Script ending
What happens to the message

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:

Field
Type
Description

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

Symptom
Possible cause
Solution

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.

Last updated

Was this helpful?