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.

The Azure Service Bus listener properties
Attribute Description

Name*

By default, we fill this out with the technical tag, followed by a serial number. Changing the name is optional.

Enabled

Set this value to true, if you want this listener to be enabled.

Consumer Autostart

Whether the listener starts together with the interface. Set it to false to deploy the interface with the listener stopped, and start it later from the agent.

Authentication

How to prove who you are. SHARED_ACCESS_KEY (the default) asks for the namespace, the policy name and the key separately and builds the connection string for you. CONNECTION_STRING takes the whole string as the portal shows it, and is the one to use for the local emulator. CLIENT_SECRET uses a Microsoft Entra ID application registration.

Connection String*

Only shown for CONNECTION_STRING. The shared access signature of the namespace or the entity, in the form Endpoint=sb://<namespace>.servicebus.windows.net/;SharedAccessKeyName=<name>;SharedAccessKey=<key>. For the local emulator, append ;UseDevelopmentEmulator=true. The Constructor shows it masked. To keep the key out of the flow, tick the Dynamic checkbox next to the field, or enter ${servicebus.connection-string} and set that property once per agent — see Keeping the connection string out of the flow.

Fully Qualified Namespace*

Shown for SHARED_ACCESS_KEY and CLIENT_SECRET. The namespace to connect to, in the form <namespace>.servicebus.windows.net. A namespace pasted from the Azure portal, with sb:// in front or a slash behind, is accepted as well.

Shared Access Key Name*

Only shown for SHARED_ACCESS_KEY. Name of the policy, as the Azure portal lists it under Shared access policies.

Shared Access Key*

Only shown for SHARED_ACCESS_KEY. The primary or secondary key of that policy. The Constructor shows it masked. Tick the Dynamic checkbox next to the field to have the key asked for when the interface is installed, once per environment; a key shared by every flow on one agent can instead be ${servicebus.shared-access-key} in the agent properties.

Tenant ID*

Only shown for CLIENT_SECRET. The directory (tenant) ID of the application registration.

Client ID*

Only shown for CLIENT_SECRET. The application (client) ID of the registration.

Client Secret*

Only shown for CLIENT_SECRET. The secret of the registration, which needs a Service Bus role such as Azure Service Bus Data Receiver on the namespace or the entity. The Constructor shows it masked.

Entity Type

Whether this listener reads a QUEUE (the default) or a TOPIC.

Queue Name*

Only shown for QUEUE. Name of the queue to read. The queue has to exist already; the agent never creates entities.

Topic Name*

Only shown for TOPIC. Name of the topic.

Subscription Name*

Only shown for TOPIC. Name of the subscription on that topic to read from.

Settlement Mode

When the message is removed from the broker. The default is COMPLETE_ON_HANDOFF. See Settlement modes.

Error Action

Only shown for FLOW_SETTLED. What happens to the message when the flow fails: ABANDON (the default) offers it again, DEAD_LETTER moves it to the dead-letter queue at once.

Max Settle Wait (seconds)

Only shown for FLOW_SETTLED. How long the listener waits for a flow that ends without settling the message, such as a filter that drops it, before it offers the message again. A flow that is still running is waited for up to Max Auto Lock Renew Duration. The default is 300.

Session Enabled

Set this to true to process the messages of each session in order. The entity itself has to require sessions. The default is false.

Max Concurrent Sessions (advanced)

Only shown when Session Enabled is true. How many sessions are processed at the same time. The default is 1.

Body Type

TEXT (the default) places the body in the message part as text, BINARY places it as raw bytes. Use BINARY for anything that is not text, such as a PDF or a compressed file.

MessagePart Out

Name of the MessagePart the message body is placed in. The default is msgprt0.

Sub Queue (advanced)

NONE (the default) reads the queue or subscription itself. DEAD_LETTER_QUEUE reads its dead-letter queue instead — the side queue Azure moves messages to when they could not be processed — which is how you build a flow that reprocesses them. TRANSFER_DEAD_LETTER_QUEUE is for messages that failed while being forwarded to another queue. Cannot be combined with Session Enabled.

Transport Type (advanced)

AMQP (the default) connects on port 5671. Choose AMQP_WEB_SOCKETS to tunnel over port 443 when a proxy or firewall blocks that port.

Charset (advanced)

Only shown for TEXT. The character set the body is decoded with. The default is UTF-8.

Max Auto Lock Renew Duration (seconds) (advanced)

Only shown for COMPLETE_ON_HANDOFF and FLOW_SETTLED. How long the hold on a received message keeps being renewed while the flow runs. The default is 300. Set it to 0 to leave the lock duration set on the queue in Azure as the deadline; when that passes mid-flow, the message is delivered again and may be handled twice.

Max Concurrent Calls (advanced)

How many messages are handed to the flow at the same time. The default is 1. A higher value loses the order in which the broker delivered the messages.

Prefetch Count (advanced)

How many messages are fetched ahead. Leave this at 0 unless throughput demands more: prefetched messages can be lost when the flow stops.

Description

Description of the specific listener. This is for documentation purposes.

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:

  1. In the Connection String field, enter ${servicebus.connection-string}.

  2. On the agent, add that property to conf/connectplaza-agent.properties:

    servicebus.connection-string=Endpoint=sb://<namespace>.servicebus.windows.net/;SharedAccessKeyName=<name>;SharedAccessKey=<key>
  3. 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 ${servicebus.connection-string}, and the interface fails to start with a connection error that names it.

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

servicebus_sequence_number

The number Azure gave the message in the queue.

servicebus_delivery_count

How many earlier attempts there were, so a first delivery is 0.

Present when the message carries them:

Property Description

servicebus_message_id

The identifier of the message.

servicebus_correlation_id

The correlation id the sender set.

servicebus_session_id

The session the message belongs to.

servicebus_subject

The subject, also called the label.

servicebus_content_type

The content type, for example application/json.

servicebus_to

The To the sender set.

servicebus_reply_to

Where the sender asks for an answer.

servicebus_reply_to_session_id

The session to answer in.

servicebus_partition_key

The partition the message belongs to.

servicebus_enqueued_time

When Azure accepted the message.

servicebus_locked_until

Until when this listener holds the message.

servicebus_scheduled_enqueue_time

When the message was scheduled to appear.

servicebus_expires_at

When Azure discards the message.

servicebus_time_to_live

How long the message may stay on the queue or topic.

servicebus_app_<name>

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

servicebus_dead_letter_reason

Why the message was dead-lettered.

servicebus_dead_letter_error_description

The longer explanation stored with it.

servicebus_dead_letter_source

The queue it was dead-lettered from.

servicebus_lock_token

How the flow settles this message. Peek-lock modes only.

servicebus_settlement_mode

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.