Azure Service Bus emulation
Azure Service Bus emulation separates the HTTP management view from the AMQP message path. The emulator manages namespaces and entities through Service Bus-compatible requests, then projects that topology into one Apache ActiveMQ Artemis sidecar for each live namespace. This lets clients create queues, topics, subscriptions, and rules over HTTP and use AMQP or AMQPS for message work.
System boundary
Service Bus planes
The Service Bus system has two connected planes. The management plane describes namespaces and entities. The data plane carries messages and applies broker-backed delivery behavior. The sidecar is created only for live namespaces, so mocked mode exposes management state without an AMQP path.
For shared request routing and authentication, see Core routing and auth. For the sidecar extensions that add Service Bus behavior, see Artemis protocol patches and broker plugins. For persistence choices, see Storage backends, and for client contract coverage, see Compatibility tests.
References: src/…/ServiceBusNamespaceManager.java• L39-49 src/…/ServiceBusNamespaceManager.java• L116-125
Namespace lifecycle
Each active namespace has one Artemis sidecar and one set of client endpoints. The emulator can start the default namespace at boot, start a named namespace through management, or start a namespace lazily when an entity operation needs it. Mocked mode registers the namespace without creating a broker.
Live startup removes an old sidecar, prepares the broker and its TLS material, installs the Service Bus extensions, verifies that both AMQP and AMQPS acceptors answer at the protocol level, waits for the CBS responder to start, and registers the namespace. A failed start records a health problem and removes partial resources. Application shutdown stops responders and all running sidecars. Sidecars are labeled so orphan cleanup can remove resources owned by this emulator without removing unrelated containers.
Every fresh broker starts with no entities. After the broker becomes ready, a broker-start event causes the emulator to replay stored queues, topics, subscriptions, and their rules into Artemis. This restores topology after a broker restart, but messages remain in the broker and are not restored from management storage.
ARM namespace creation follows the same lifecycle. A namespace resource owns the broker namespace with the same name, and a child request can start a stored namespace again after an application restart. Namespace deletion removes its entities, management records, and broker.
References: src/…/ServiceBusNamespaceManager.java• L196-309 src/…/ServiceBusNamespaceManager.java• L364-433 src/…/ServiceBusBrokerStarted.java• L3-4 src/…/ServiceBusHandler.java• L1030-1092 src/…/ServiceBusArmService.java• L229-247 src/…/ServiceBusArmService.java• L280-365
Artemis readiness
Artemis readiness means that the broker accepts its protocol, not only that a published port accepts a TCP connection. The plain AMQP check sends the protocol header and requires the matching reply. The AMQPS check completes a TLS handshake with the certificate generated for that namespace. The checks retry until the startup deadline so clients do not use a port forwarder while the broker is still starting.
References: src/…/ArtemisReadinessProbe.java• L23-60 src/…/ArtemisReadinessProbe.java• L68-100 src/…/ServiceBusNamespaceManager.java• L265-274
Management plane
Namespace and entity management
The HTTP management service presents Azure-style namespace, queue, topic, subscription, and rule resources. The handler resolves the namespace and resource, reads the stored description, and asks the namespace manager to mirror entity changes in the live sidecar.
Queue resources provide direct message destinations. Topic resources provide fan-out. Subscriptions provide named consumer views over topics, and rules control which messages enter each view. Namespace responses expose the AMQP and AMQPS endpoints and the local certificate needed by TLS clients.
Entity create requests accept the Service Bus settings that affect delivery and lifetime. They also retain descriptive settings such as size, idle deletion, batching, user metadata, and topic ordering so later management responses preserve the client-visible resource shape. XML management paths, ARM JSON paths, and programmatic setup use the same validation rules.
References: src/…/ServiceBusHandler.java• L39-73 src/…/ServiceBusHandler.java• L286-317 src/…/ServiceBusArmService.java• L53-80 src/…/ServiceBusArmSurface.java• L20-64 src/…/ServiceBusEntities.java• L23-30 src/…/ServiceBusEntityXml.java• L8-13
Azure resource management
The ARM management path exposes Microsoft.ServiceBus resources for namespaces and their queues, topics, subscriptions, rules, authorization rules, network rule sets, and name checks. It gives infrastructure tools a resource-manager view while sharing entity state with the HTTP management API and the broker.
ARM namespace records keep Azure-facing resource data such as location, SKU, tags, identity, writable properties, and timestamps. Entity records remain the common Service Bus entity model. ARM-only properties are retained beside those records so later reads can return the shape sent by the client without creating a second entity system.
Authorization rules provide stored rights and generated keys for namespaces, queues, and topics. Connection strings point to the emulator's AMQP endpoint and mark the development emulator mode. Network rule sets return the supported local view, while geo-disaster recovery pairing is not emulated.
References: src/…/ServiceBusArmSurface.java• L16-64 src/…/ServiceBusArmService.java• L53-80 src/…/ServiceBusArmService.java• L280-365 src/…/ServiceBusArmService.java• L509-570 src/…/ServiceBusArmService.java• L909-1011 src/…/ServiceBusArmModels.java• L11-87
Entity topology
The management model maps each direct destination to a durable broker path. A topic adds a fan-out path. Each subscription gets its own durable path and filter. Queues and subscriptions also have a dead-letter path for messages that exceed delivery limits or expire.
The namespace manager projects these paths through the Artemis management interface without restarting the sidecar. Entity descriptions expose active and dead-letter counts. Live namespaces read both values for each queue in one bounded request. If the broker is unavailable or an individual value is invalid, the API returns zero for the affected count instead of failing the full management response. Mocked namespaces also return zero.
ARM entity operations use the shared entity access layer. This makes an entity created through ARM visible to the Atom API and provisions it in the broker through the same create and delete paths. Entity names compare without regard to case, while the stored resource keeps the casing used when it was created.
References: src/…/ServiceBusNamespaceManager.java• L444-477 src/…/ServiceBusNamespaceManager.java• L491-724 src/…/ServiceBusHandler.java• L547-585 src/…/ServiceBusHandler.java• L1030-1092 src/…/ServiceBusArmService.java• L574-753 src/…/ServiceBusEntities.java• L23-30
Entity policies
Entity descriptions carry delivery rules that clients expect to read and use. These rules cover message lifetime, duplicate detection, delivery attempts, lock duration, sessions, and dead-lettering on expiry. The same policy must remain aligned between stored state and the broker path.
The management model also keeps client-visible metadata that does not change broker behavior. Missing values use Service Bus defaults. Values that affect delivery are checked before storage, including positive message lifetime, bounded duplicate-detection history, valid delivery limits, and lock duration within the supported range.
Lock behavior applies to both active and dead-letter paths. Session grouping applies only where the entity enables sessions, so dead-lettered messages remain available without consumer pinning. A subscription uses the more restrictive lifetime when its topic and subscription use different message lifetimes.
References: src/…/ServiceBusEntityXml.java• L16-24 src/…/ServiceBusEntityXml.java• L27-130 src/…/ServiceBusModels.java• L18-114 src/…/ServiceBusModels.java• L159-198 src/…/ServiceBusArmService.java• L1040-1102 src/…/ServiceBusNamespaceManager.java• L491-585 src/…/ServiceBusHandler.java• L1001-1015
Client paths
HTTP management path
An administration client sends an HTTP request to a Service Bus route. The handler resolves the namespace and resource, returns the matching XML or JSON response, and triggers sidecar projection when an entity changes. This keeps later AMQP links aligned with the management view.
The service supports the Service Bus Atom-style paths used by administration clients, custom namespace paths used by local setup, and ARM resource-manager paths used by infrastructure tools. The namespace management response supplies the active AMQP and AMQPS endpoints and the local certificate needed for TLS clients. Invalid entity settings return a client error before the resource is created, while accepted descriptive settings remain available in later entity responses.
References: src/…/ServiceBusHandler.java• L139-199 src/…/ServiceBusHandler.java• L251-317 src/…/ServiceBusArmService.java• L167-255 src/…/ServiceBusArmService.java• L1040-1102 src/…/ServiceBusEntityXml.java• L27-193
AMQP data path
An application client connects to the endpoint for its namespace and attaches a link to a queue or subscription. Artemis then carries transfers and applies broker-backed delivery behavior such as settlement, locks, expiry, duplicate detection, filtering, and dead-letter movement. Mocked mode has no broker and therefore has no AMQP data path.
The sidecar supports plain AMQP and AMQPS. The latter uses the generated local certificate. Service Bus protocol extensions let standard client links complete their connection and entity setup against the emulator.
References: src/…/ServiceBusNamespaceManager.java• L231-288 src/…/ServiceBusConfigGenerator.java• L34-56
CBS authentication path
Claims-Based Security (CBS) is the AMQP exchange that a Service Bus SDK performs before it attaches an entity link. The emulator routes put-token requests to an internal responder. The responder returns an accepted response on the $cbs response link and keeps the requesting connection identifier so the correct client receives the reply.
The responder does not validate the token or shared access signature. It provides the protocol step needed by local clients. If the broker closes the responder connection, the emulator recreates it after a delay. Stopping the namespace stops the responder.
References: src/…/ServiceBusConfigGenerator.java• L20-25 src/…/ServiceBusConfigGenerator.java• L89-117 src/…/ServiceBusNamespaceManager.java• L269-274 src/…/ServiceBusCbsResponder.java• L23-40 src/…/ServiceBusCbsResponder.java• L86-217
Artemis sidecar coordination
Topology projection
The sidecar starts with broker-wide settings, protocol hooks, and only the shared DLQ and CBS nodes. It does not pre-create entity topology or auto-create addresses and queues. The namespace manager then uses the broker management interface to add or remove resources as HTTP operations change the Service Bus model. This avoids a broker restart for each topology change.
The projection follows these relationships:
- A queue maps to a direct broker path and a paired dead-letter path.
- A topic maps to an ingress path and a hidden fan-out path.
- A subscription maps to a durable queue, a dead-letter queue, and a divert from the topic fan-out path.
- A subscription rule becomes the filter on that divert.
The manager also applies lock, session, expiry, delivery-attempt, and duplicate-detection settings to the related broker resources. Rule updates change the existing divert without replacing the subscription queue or its receivers.
References: src/…/ServiceBusConfigGenerator.java• L75-118 src/…/ServiceBusNamespaceManager.java• L491-585 src/…/ServiceBusNamespaceManager.java• L610-724
Protocol patches and broker plugins
The sidecar receives an embedded Service Bus extension and patched AMQP libraries when it starts. Its static broker configuration also registers the plugins that provide Service Bus behavior that the base Artemis broker does not provide alone, including protocol and message-handling semantics.
The patched libraries and Artemis image form one version contract. The emulator loads their versions from one build-generated record and checks that the embedded resources match the sidecar image. See Artemis protocol patches and broker plugins for the child-page view of these extensions.
References: src/…/ServiceBusConfigGenerator.java• L58-74 src/…/ServiceBusNamespaceManager.java• L54-60 src/…/ServiceBusNamespaceManager.java• L231-259 src/…/ArtemisPatchVersions.java• L7-46
Management synchronization
Jolokia synchronizes live Artemis topology with management state. Most entity changes store the management description and then project the matching broker resources. When a broker starts empty, the broker-start event replays stored entities and rebuilds subscription filters from the stored rules.
Rule replacement uses a safer sequence: the broker filter changes first, and the stored rules commit second. If the storage change fails, the previous broker filter is restored when possible. A rule action is retained in management state but is not applied to delivered messages.
If a normal projection fails, the management response can still expose the stored entity even though Artemis lacks the matching resource. The namespace remains available, but the stored topology and broker topology then need repair together before AMQP use.
References: src/…/ServiceBusHandler.java• L785-876 src/…/ServiceBusHandler.java• L1149-1297 src/…/ServiceBusNamespaceManager.java• L861-922
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the CBS address, responder target, accepted AMQP mechanisms, response status, and connection identifier aligned across broker configuration and the CBS responder.
- Keep the embedded extension, patched AMQP resources, broker plugins, and Artemis image on one version contract.
- Keep the static broker topology limited to the shared DLQ and CBS nodes. Entity resources must continue to be created through management projection rather than broker auto-creation.
- Keep XML, ARM JSON, and programmatic entity setup on the same validation and default rules.
- When an entity policy or descriptive setting changes, update both the client-facing description and the stored model. Update the matching active and dead-letter broker paths when the setting affects delivery.
- When topic or subscription names change, update every related address, queue, divert, management path, and dead-letter path.
- When namespace startup or cleanup changes, preserve stale-resource removal, responder shutdown, port release checks, health failure reporting, and owner-scoped orphan cleanup.
- When readiness checks change, keep plain AMQP protocol-header validation and namespace-certificate TLS validation before the namespace becomes available.
- When count reads change, keep active and dead-letter queue names paired and preserve partial results for bad individual broker values.
- When broker-start restoration changes, preserve the replay order for topics, subscriptions, and rules, and keep message data separate from stored topology.
- When rule actions change, preserve the contract that the action is stored and reported but not applied to delivered messages.
- When ARM resource shapes change, keep namespace resource data, ARM-only entity properties, shared entity records, authorization rules, and global namespace names consistent.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Service Bus runs in mocked mode | Management requests work, but AMQP and CBS clients cannot connect | Use mocked mode only for management-plane flows |
| A published Artemis port accepts TCP before the broker accepts AMQP | A client can connect and receive a remote transport close during startup | Require an AMQP protocol-header reply and an AMQPS TLS handshake before registration |
| Artemis is not ready before the readiness deadline | The namespace cannot provide its AMQP data path | Retry protocol-level checks during namespace startup |
| Startup fails after partial sidecar creation | A stale container or port can block a later retry | Stop the responder and confirm sidecar removal |
| An entity setting is invalid or outside the supported range | The management request is rejected and no new entity is created | Apply the shared XML, ARM JSON, and programmatic validation before storage |
| A broker projection fails after management state is stored | A client can see an entity that has no matching broker resource | Repair the stored state and broker topology together |
| An entity is expected to exist from static broker configuration | A client cannot use the entity because Service Bus entities are not auto-created | Create entity resources through the management projection path |
| A broker count read fails | The affected active or dead-letter count appears as zero | Treat zero as a degraded count result and check broker health |
| Patched libraries do not match the sidecar image | The broker can fail to start or expose an incompatible protocol | Keep build versions, embedded resources, and image tags aligned |
| The CBS reply lacks the requesting connection identifier | The SDK does not receive the response on its CBS link | Preserve the connection identifier on the response |
| A stored entity cannot be replayed after broker start | Management state exists, but AMQP clients cannot use that entity | Check broker-start restoration logs and repair the stored and broker topology |
| A rule action is supplied | The rule action is visible in management state but has no effect on delivered messages | Treat rule actions as stored metadata only |
| An ARM namespace is stored but its broker is not running | ARM child operations cannot reach the entity namespace | Start the broker before handling child resources |
| ARM-only entity properties are treated as the entity record | Later ARM reads lose client-visible fields or diverge from Atom reads | Keep ARM properties beside the shared entity model |
| A namespace is renamed or created with a conflicting global name | Resource-manager state and the Service Bus endpoint identity disagree | Apply namespace name and global-name checks before creation |
Key files
| File | Why to read it |
|---|---|
| src/…/ServiceBusHandler.java | Defines the HTTP management boundary for namespaces, entities, rules, counts, and broker-start restoration |
| src/…/ServiceBusArmService.java | Defines the Azure resource-manager view for namespaces, entities, authorization, network rules, and connection data |
| src/…/ServiceBusArmSurface.java | Defines the Service Bus ARM resource types and namespace name rules |
| src/…/ServiceBusArmModels.java | Defines stored ARM namespace, authorization, and ARM-only property records |
| src/…/ServiceBusEntities.java | Connects ARM entity operations to the shared entity store and handler paths |
| src/…/ServiceBusEntityXml.java | Defines shared defaults and validation for entity settings from management payloads and programmatic setup |
| src/…/ServiceBusModels.java | Defines the stored descriptions for queues, topics, subscriptions, and rules |
| src/…/ServiceBusNamespaceManager.java | Coordinates sidecars, endpoints, topology projection, counts, health, and cleanup |
| src/…/ServiceBusBrokerStarted.java | Defines the event that links broker readiness to topology restoration |
| src/…/ArtemisReadinessProbe.java | Shows how startup confirms real AMQP and AMQPS broker readiness |
| src/…/ServiceBusContainerManager.java | Defines boot loading, lazy start, mocked mode, and shutdown |
| src/…/ServiceBusTopologyLoader.java | Applies declarative topology through the normal management path |
| src/…/ServiceBusConfigGenerator.java | Defines broker endpoints, static DLQ and CBS nodes, disabled auto-creation, and broker plugins |
| src/…/ServiceBusCbsResponder.java | Provides the CBS handshake, connection-scoped replies, and reconnect behavior for AMQP clients |
| src/…/ArtemisPatchVersions.java | Defines the shared version contract for patched resources and the sidecar image |
| docs/service-bus-artemis-integration.md | Explains the Artemis protocol patches and broker plugins in detail |
| docs/compatibility-tests.md | Explains client contract coverage for the Service Bus paths |
| docs/storage-backends.md | Explains how the management description is persisted |