Skip to main content

RabbitMQ

RabbitMQ event integrations consume messages from a RabbitMQ queue and trigger event handlers as each message arrives. Use them for asynchronous task processing, event-driven workflows, and integrations where producers publish messages that must be reliably consumed and processed.

Creating a RabbitMQ service

  1. Click + Add Artifact in the canvas or click + next to Entry Points in the sidebar.

  2. In the Artifacts panel, select RabbitMQ under Event Integration.

  3. In the creation form, fill in the following fields:

    RabbitMQ Event Integration creation form

    FieldDescriptionDefault
    Listener NameIdentifier for the listener created with this service.rabbitmqListener
    HostHostname or IP address of the RabbitMQ broker.localhost
    PortPort used to connect to the broker.5672
    Queue NameName of the RabbitMQ queue to listen to.myQueue
  4. Click Create.

  5. WSO2 Integrator opens the service in the Service Designer. The header shows the attached listener pill and the queue name pill.

    Service Designer showing the RabbitMQ service canvas

  6. Click + Add Handler to define how incoming messages are processed.

Service configuration

Service configuration sets the queue the service subscribes to and applies advanced queue-level settings.

In the Service Designer, click the Configure icon in the header to open the RabbitMQ Event Integration Configuration panel. Select RabbitMQ Event Integration in the left panel.

RabbitMQ Event Integration Configuration panel

FieldDescription
Queue NameName of the queue this service listens to.
Service ConfigurationAdvanced queue-level settings as a @rabbitmq:ServiceConfig record expression (e.g., { autoAck: false }).

Listener configuration

The listener connects to the RabbitMQ broker and manages the consumer lifecycle.

In the RabbitMQ Event Integration Configuration panel, select rabbitmqListener under Attached Listeners to configure the listener.

Listener configuration — connection and authentication fields

FieldDescriptionDefault
NameIdentifier for the listener.rabbitmqListener
HostHostname or IP address of the RabbitMQ broker.localhost
PortPort used to connect to the broker.5672
Qos SettingsConsumer prefetch settings. Controls how many unacknowledged messages can be in flight.()
UsernameUsername for broker authentication.
PasswordPassword for broker authentication.
Virtual HostVirtual host to use when connecting to the broker.
Connection TimeoutTCP connection establishment timeout in seconds. Set to 0 for infinite.0.0
Handshake TimeoutAMQP 0-9-1 protocol handshake timeout in seconds.0.0
Shutdown TimeoutShutdown timeout in seconds. Set to 0 for infinite. If consumers exceed this timeout, any remaining queued deliveries will be lost. Default is 10.0.0
HeartbeatInitially-requested heartbeat timeout in seconds. Set to 0 for none.0.0
ValidationEnable constraint validation on incoming message content.
Secure SocketSSL/TLS configuration for secure connections (certificate path and password).
AuthAuthentication record with username and password fields.

Click Save Changes to apply updates.

Event handlers

An event handler is a remote function that WSO2 Integrator calls for each event received from the queue.

Adding an event handler

In the Service Designer, click + Add Handler. A Select Handler to Add panel opens on the right listing the available event types.

onMessage — opens a configuration panel before saving:

onMessage handler configuration panel

FieldDescription
+ Define ContentDefine the expected content type of the incoming message (e.g., a typed record).
CallerWhen selected, includes rabbitmq:Caller as a parameter in the handler, enabling manual acknowledgment (basicAck) or rejection (basicNack) of messages.

Click Save to add the handler.

onRequest and onError — added directly without additional configuration.

Handler types

HandlerTriggered whenUse when
onMessageA new message arrives on the queueStandard one-way message consumption
onRequestAn RPC request message arrives (has a replyTo property)Request/reply messaging patterns
onErrorA handler returns an error or message processing failsLogging failures and routing to dead-letter queues

Message type

Each handler receives a rabbitmq:AnydataMessage parameter with the message content and metadata.

FieldTypeDescription
contentanydataMessage payload. Use message.content.ensureType() to cast to a typed record.
routingKeystringRouting key used when the message was published.
exchangestringExchange the message was published to. Empty string for the default exchange.
deliveryTagintUnique delivery identifier. Used with caller->basicAck(deliveryTag) for manual acknowledgment.
propertiesrabbitmq:BasicProperties?AMQP message properties including replyTo, correlationId, contentType, and headers.

What's next