Skip to main content

Azure Service Bus

Azure Service Bus event integrations consume messages from a queue or topic subscription and trigger event handlers as each message arrives. Use them for reliable enterprise messaging, decoupled service-to-service communication, and workflows that require ordered or transactional message delivery.

Creating an Azure service bus service

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

  2. In the Artifacts panel, select Azure Service Bus under Event Integration.

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

    Azure Service Bus Event Integration creation form

    FieldDescription
    Connection StringService Bus connection string with Shared Access Signatures. Format: Endpoint=sb://<NAMESPACE>.servicebus.windows.net/;SharedAccessKeyName=<KEY_NAME>;SharedAccessKey=<KEY_VALUE>. Required.
    Entity ConfigConfiguration for the queue or topic subscription to connect to. Accepts a QueueConfig or TopicSubsConfig record expression. Required.

    Expand Advanced Configurations to set the listener name.

    FieldDescriptionDefault
    Listener NameIdentifier for the listener created with this service.asbListener
  4. Click Create.

  5. WSO2 Integrator opens the service in the Service Designer. The canvas shows the attached listener pill and the Event Handlers section.

    Service Designer showing the Azure Service Bus service canvas

  6. Click + Add Handler to add event handlers.

Listener configuration

In the Service Designer, click the Configure icon in the header to open the Azure Service Bus Event Integration Configuration panel. Select asbListener under Attached Listeners to configure the listener.

Listener configuration — connection string and entity config

FieldDescriptionDefault
NameIdentifier for the listener.asbListener
Connection StringService Bus connection string with Shared Access Signatures.Required
Entity ConfigConfiguration for the target queue or topic subscription. The entity type is determined by the record type — use QueueConfig for queues or TopicSubsConfig for topic subscriptions.Required
Receive ModeHow messages are retrieved from the entity. PEEK_LOCK holds a lock on the message until completed or abandoned. RECEIVE_AND_DELETE removes the message immediately on receipt.PEEK_LOCK
Max Auto Lock Renew DurationMaximum lock renewal duration in seconds under PEEK_LOCK mode. Set to 0 to disable auto-renewal. Auto-renewal is disabled for RECEIVE_AND_DELETE mode.300
Amqp Retry OptionsRetry configuration for the underlying AMQP message receiver.{}
Additional ValuesKey-value pairs for additional connection or entity configuration.{}
Auto CompleteWhen enabled, messages are automatically completed on successful handler execution and abandoned on failure.true
Prefetch CountNumber of messages to prefetch from the broker.0
Max ConcurrencyMaximum number of concurrent messages this listener processes at one time.1

Click + Attach Listener to attach an additional listener to the same service.

Click Save Changes to apply updates.

Event handlers

Azure Service Bus services support two handler types: onMessage and onError, both added directly without additional configuration.

Adding an event handler

In the Service Designer, click + Add Handler. The Select Handler to Add panel lists onMessage and onError. Click either handler to add it directly. No additional configuration is required.

HandlerTriggered when
onMessageA new message arrives from the queue or topic subscription
onErrorA message retrieval or processing error occurs

Message type

The onMessage handler receives an asb:Message parameter with the message content and metadata.

FieldTypeDescription
bodyanydataMessage payload. Use message.body.ensureType() to cast to a typed record.
contentTypestring?MIME content type of the message body. Use asb:TEXT, asb:JSON, asb:XML, or asb:BYTE_ARRAY.
messageIdstring?Unique message identifier set by the sender.
correlationIdstring?Correlation identifier for request/reply patterns.
labelstring?Application-specific label. Corresponds to the Azure Service Bus "Subject" property.
tostring?Destination address of the message.
replyTostring?Address to send replies to.
replyToSessionIdstring?Session ID for the reply destination.
sessionIdstring?Session identifier for session-aware entities.
partitionKeystring?Partition key for partitioned queues and topics.
timeToLiveint?Message expiry duration in seconds.
applicationPropertiesApplicationProperties?Custom application properties. Access values via message.applicationProperties?.properties.
sequenceNumberint?Unique sequence number assigned by the broker. Read-only.
lockTokenstring?Lock token used for settlement in PEEK_LOCK mode. Read-only.
deliveryCountint?Number of times delivery has been attempted.
enqueuedTimestring?UTC time when the message was added to the queue.
enqueuedSequenceNumberint?Sequence number assigned when the message was first enqueued.
deadLetterReasonstring?Reason the message was moved to the dead-letter sub-queue.
deadLetterErrorDescriptionstring?Description of the error that caused dead-lettering.
deadLetterSourcestring?Name of the entity where the message was dead-lettered.
statestring?Current message state: Active, Deferred, or Scheduled.

What's next