Azure Service Bus listener
1. Overview
This listener receives messages from an Azure Service Bus queue or topic subscription and starts the flow once for every message. Unlike a polling listener there is no schedule: Azure pushes the message to the agent as soon as it arrives.
The body of the message becomes the content of the MessagePart Out you configure, and everything Service Bus records on the message — subject, content type, session and correlation id, delivery count, time to live, dead-letter reason, and any application property the sender added — is placed on the ConnectMessage as a property.
A flow started by this listener must end in a producer. Which producer is up to you; the Azure Service Bus sender is the natural partner when you forward the message to another entity.
2. Attributes
In the table below, you will find an explanation of these properties. All attributes with a * are mandatory. Attributes marked (advanced) are hidden until you open the advanced section; their defaults suit almost every flow.
|
|
3. Settlement modes
Settling a message is telling the broker what happened to it. The mode you choose decides how much you are willing to lose if something goes wrong, and it cannot change per message: two behaviours means two listeners.
| Mode | Guarantee | What happens |
|---|---|---|
RECEIVE_AND_DELETE |
At most once |
Azure deletes the message as it is delivered. The fastest option, and the message is gone if the flow never finishes. |
COMPLETE_ON_HANDOFF |
At least once, up to the hand-off |
The message is removed as soon as the flow has accepted it. This is the default and suits most integrations. |
FLOW_SETTLED |
At least once, end to end |
The message stays on the broker for the whole flow and is removed only once the flow has delivered it at its producer. When the flow fails, Error Action decides whether it is offered again or dead-lettered. |
FLOW_SETTLED gives the same guarantee as the JMS listener’s Flow Transacted mode. A few things are worth knowing before you choose it:
-
A message that is offered again keeps being offered until the queue’s own delivery limit moves it to the dead-letter queue.
-
An Aggregator is not supported in a FLOW_SETTLED flow, because merging messages drops the reference the listener needs to settle them.
-
A split message is removed only once every part has reached the producer. The parts can only be counted when the splitter numbers them: on an Unzip or Generic service, turn on Apply Sequence. Without it, the first part removes the whole message.
-
A flow called through a Flow Gateway does not settle the message, even when it ends in a Reply producer. The flow that received the message settles it, at its own end.
-
A message whose body the listener cannot read, such as an AMQP sequence, never reaches the flow. It goes to the flow’s exception handling, and Error Action decides what happens to it on the broker.
If you want the flow itself to decide, add the Azure Service Bus settle component anywhere in the flow. The first decision made about a message is the one that counts.
4. Keeping the connection string out of the flow
A connection string contains a key, and the same flow usually runs on more than one environment. There are two ways to keep the key out of the design, and they answer different questions.
Per environment, asked when the interface is installed. Tick the Dynamic checkbox next to the field. The value is then not stored in the flow at all: whoever installs the interface fills it in. This is the usual choice, and it works the same way for Shared Access Key and Client Secret.
One value for every flow on the same agent. Point the field at a property of the agent instead:
-
In the Connection String field, enter
${servicebus.connection-string}. -
On the agent, add that property to
conf/connectplaza-agent.properties:servicebus.connection-string=Endpoint=sb://<namespace>.servicebus.windows.net/;SharedAccessKeyName=<name>;SharedAccessKey=<key> -
Restart the agent so it reads the file.
Every environment then holds its own key, the flow travels between them unchanged, and the key never appears in the design. The same works for the Client Secret of an Entra ID registration.
|
The property has to exist on the agent. When it does not, the field keeps the literal text |
5. What the flow receives
Every message arrives with its body in the MessagePart Out and these properties on the ConnectMessage.
Always present:
| Property | Description |
|---|---|
|
The number Azure gave the message in the queue. |
|
How many earlier attempts there were, so a first delivery is 0. |
Present when the message carries them:
| Property | Description |
|---|---|
|
The identifier of the message. |
|
The correlation id the sender set. |
|
The session the message belongs to. |
|
The subject, also called the label. |
|
The content type, for example |
|
The |
|
Where the sender asks for an answer. |
|
The session to answer in. |
|
The partition the message belongs to. |
|
When Azure accepted the message. |
|
Until when this listener holds the message. |
|
When the message was scheduled to appear. |
|
When Azure discards the message. |
|
How long the message may stay on the queue or topic. |
|
Every application property the sender added, under its own name. |
When reading a dead-letter queue, and in the two modes that hold the message (COMPLETE_ON_HANDOFF and FLOW_SETTLED):
| Property | Description |
|---|---|
|
Why the message was dead-lettered. |
|
The longer explanation stored with it. |
|
The queue it was dead-lettered from. |
|
How the flow settles this message. Peek-lock modes only. |
|
The mode the listener runs in. Peek-lock modes only. |
6. Reading what failed
Set Sub Queue to DEAD_LETTER_QUEUE and the listener reads the dead-letter queue of the entity instead of the entity itself. The flow then receives the messages another flow could not process, with servicebus_dead_letter_reason and servicebus_dead_letter_error_description explaining why.
This is a separate interface from the one that reads the queue normally. A dead-letter queue does not require sessions, so leave Session Enabled off even when the entity itself uses them.