Cameleer

Azure Service Bus component

The azure-servicebus component sends messages to and receives messages from Azure Service Bus queues and topic subscriptions over AMQP 1.0, with peek-lock, sessions, scheduling, dead-lettering and transactions.

Scheme: azure-servicebus: · Crate: cameleer-amqp10 · Cargo feature: amqp10 · Consumer: yes · Producer: yes · Apache Camel: Azure ServiceBus

When to use it

  • Reliable enterprise messaging between services on Azure (orders, payments, commands).
  • Publish to a topic and let several subscriptions process the same message.
  • Ordered processing per customer or device with sessions.
  • Schedule messages for later delivery, or defer them and fetch them by sequence number.

URI format

text
azure-servicebus:queueOrTopicName[?options]

Authenticate with a connectionString, with fullyQualifiedNamespace + sharedAccessName + sharedAccessKey, or with Microsoft Entra ID (credentialType=AZURE_IDENTITY).

Example

Send an order to a queue:

yaml example: azure-servicebus-send-order
- route:
    id: send-order
    from:
      uri: "timer:new-order?repeatCount=1"
      steps:
        - setBody:
            constant: '{"orderId":"o-1001","item":"camel saddle"}'
        - setHeader:
            name: CamelAzureServiceBusContentType
            constant: application/json
        - to: "azure-servicebus:orders?connectionString=RAW({{env:SERVICEBUS_CONNECTION_STRING:Endpoint=sb://my-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=change-me}})"

Process the queue with peek-lock. A message is completed when the route succeeds, and abandoned (redelivered) when it fails:

yaml example: azure-servicebus-process-orders
- route:
    id: process-orders
    from:
      uri: "azure-servicebus:orders?connectionString=RAW({{env:SERVICEBUS_CONNECTION_STRING:Endpoint=sb://my-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=change-me}})&maxConcurrentCalls=4"
      steps:
        - log: "order ${header.CamelAzureServiceBusMessageId} (delivery ${header.CamelAzureServiceBusDeliveryCount}): ${body}"
        - to: "log:orders"

Rust DSL

rust
ctx.add_routes(|b| {
    b.from("azure-servicebus:orders?connectionString=RAW({{env:SERVICEBUS_CONNECTION_STRING:Endpoint=sb://my-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=change-me}})&maxConcurrentCalls=4")
        .log("order ${header.CamelAzureServiceBusMessageId} (delivery ${header.CamelAzureServiceBusDeliveryCount}): ${body}")
        .to("log:orders");
})?;

Options

optiondefaultdescription
connectionStringNamespace connection string (Endpoint=sb://...;SharedAccessKeyName=...;SharedAccessKey=...; UseDevelopmentEmulator=true for the emulator).
fullyQualifiedNamespace, sharedAccessName, sharedAccessKeyInstead of a connection string.
credentialTypeCONNECTION_STRINGCONNECTION_STRING, AZURE_IDENTITY (environment, client secret or managed identity; options tenantId, clientId, clientSecret, authorityHost, managedIdentityEndpoint, managedIdentityClientId) or TOKEN_CREDENTIAL (tokenCredential=#bean).
amqpTransportTypeAMQPAMQP (port 5671) or AMQP_WEB_SOCKETS (port 443).
serviceBusTypequeuequeue or topic.
subscriptionNameSubscription of a topic consumer.
receiveModePEEK_LOCKPEEK_LOCK or RECEIVE_AND_DELETE.
consumerOperationreceiveMessagesreceiveMessages or peekMessages (without locking; peekNumMaxMessages per poll, default 10).
producerOperationsendMessagessendMessages, scheduleMessages, and the Cameleer operations receiveDeferredMessages, getSessionState, setSessionState.
scheduledEnqueueTimeEnqueue time of scheduleMessages (epoch millis or ISO-8601).
prefetchCount0Messages to prefetch.
maxConcurrentCalls1Parallel receivers.
subQueueNONEDEAD_LETTER_QUEUE reads the dead-letter queue.
enableDeadLetteringfalseDead-letter failed messages instead of abandoning them.
disableAutoCompletefalseDo not settle automatically (use CamelAzureServiceBusDisposition).
maxAutoLockRenewDurationPT5MRenew message and session locks while processing (0 disables).
sessionEnabled, sessionId, sessionIdleTimeoutfalse, , 1 sSessions: accept any or one session; release it after the idle timeout (Cameleer).
transactedfalseCameleer: send the messages of an exchange in one AMQP transaction.
binaryfalseSend the body as binary.
sasTokenTtl, idleTimeout, requestTimeout, recoveryInterval, delayConnection and polling timings.

Message headers

headerdirectiondescription
CamelAzureServiceBusMessageId, CamelAzureServiceBusCorrelationId, CamelAzureServiceBusContentType, CamelAzureServiceBusSubject, CamelAzureServiceBusTo, CamelAzureServiceBusReplyTo, CamelAzureServiceBusSessionId, CamelAzureServiceBusPartitionKey, CamelAzureServiceBusTimeToLivein/outMessage properties.
CamelAzureServiceBusApplicationPropertiesin/outApplication properties (map).
CamelAzureServiceBusReplyToSessionIdoutReply-to session.
CamelAzureServiceBusEnqueuedTime, CamelAzureServiceBusLockedUntil, CamelAzureServiceBusExpiresAtoutTimes (epoch millis).
CamelAzureServiceBusSequenceNumberin/outSequence number (set by scheduleMessages, input of receiveDeferredMessages).
CamelAzureServiceBusDeliveryCount, CamelAzureServiceBusLockTokenoutDelivery count and lock token.
CamelAzureServiceBusDeadLetterReason, CamelAzureServiceBusDeadLetterErrorDescription, CamelAzureServiceBusDeadLetterSourceoutDead-letter details.
CamelAzureServiceBusScheduledEnqueueTime, CamelAzureServiceBusProducerOperationinProducer overrides.
CamelAzureServiceBusDispositioninCameleer: settle explicitly with complete, abandon, deadLetter or defer.

Run it with Docker

sh
docker run --rm -e SERVICEBUS_CONNECTION_STRING \
  -v "$PWD:/routes:ro" pmsudhi/cameleer run /routes/orders.camel.yaml

Common questions

How do I consume a topic subscription?

azure-servicebus:events?serviceBusType=topic&subscriptionName=billing&connectionString=....

How do I read the dead-letter queue?

Add subQueue=DEAD_LETTER_QUEUE; the dead-letter reason and description are in headers.

Does it work with the Service Bus emulator?

Yes: a connection string with UseDevelopmentEmulator=true uses plain AMQP to the emulator.

Found a problem?

If something on this page doesn't match what Cameleer does, or you hit a bug while building with it, please help fix it, whether you are a person or a coding agent: open an issue that describes what you saw, then fork the repository, fix it, add or update a test, run cargo test --workspace, and open a pull request. CONTRIBUTING.md explains the ground rules.

Edit this page on GitHub