Introducing a new way to review your PRs.

Read the announcement

floci-io / floci-az

Light, fluffy, and always free - Local Azure Emulator

View on GitHub

27 documents · Updated Nov 23, 2026

docs / service-bus

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:

  1. A queue maps to a direct broker path and a paired dead-letter path.
  2. A topic maps to an ingress path and a hidden fan-out path.
  3. A subscription maps to a durable queue, a dead-letter queue, and a divert from the topic fan-out path.
  4. 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

TriggerConsequenceGuard
Service Bus runs in mocked modeManagement requests work, but AMQP and CBS clients cannot connectUse mocked mode only for management-plane flows
A published Artemis port accepts TCP before the broker accepts AMQPA client can connect and receive a remote transport close during startupRequire an AMQP protocol-header reply and an AMQPS TLS handshake before registration
Artemis is not ready before the readiness deadlineThe namespace cannot provide its AMQP data pathRetry protocol-level checks during namespace startup
Startup fails after partial sidecar creationA stale container or port can block a later retryStop the responder and confirm sidecar removal
An entity setting is invalid or outside the supported rangeThe management request is rejected and no new entity is createdApply the shared XML, ARM JSON, and programmatic validation before storage
A broker projection fails after management state is storedA client can see an entity that has no matching broker resourceRepair the stored state and broker topology together
An entity is expected to exist from static broker configurationA client cannot use the entity because Service Bus entities are not auto-createdCreate entity resources through the management projection path
A broker count read failsThe affected active or dead-letter count appears as zeroTreat zero as a degraded count result and check broker health
Patched libraries do not match the sidecar imageThe broker can fail to start or expose an incompatible protocolKeep build versions, embedded resources, and image tags aligned
The CBS reply lacks the requesting connection identifierThe SDK does not receive the response on its CBS linkPreserve the connection identifier on the response
A stored entity cannot be replayed after broker startManagement state exists, but AMQP clients cannot use that entityCheck broker-start restoration logs and repair the stored and broker topology
A rule action is suppliedThe rule action is visible in management state but has no effect on delivered messagesTreat rule actions as stored metadata only
An ARM namespace is stored but its broker is not runningARM child operations cannot reach the entity namespaceStart the broker before handling child resources
ARM-only entity properties are treated as the entity recordLater ARM reads lose client-visible fields or diverge from Atom readsKeep ARM properties beside the shared entity model
A namespace is renamed or created with a conflicting global nameResource-manager state and the Service Bus endpoint identity disagreeApply namespace name and global-name checks before creation

Key files

FileWhy to read it
src/…/ServiceBusHandler.javaDefines the HTTP management boundary for namespaces, entities, rules, counts, and broker-start restoration
src/…/ServiceBusArmService.javaDefines the Azure resource-manager view for namespaces, entities, authorization, network rules, and connection data
src/…/ServiceBusArmSurface.javaDefines the Service Bus ARM resource types and namespace name rules
src/…/ServiceBusArmModels.javaDefines stored ARM namespace, authorization, and ARM-only property records
src/…/ServiceBusEntities.javaConnects ARM entity operations to the shared entity store and handler paths
src/…/ServiceBusEntityXml.javaDefines shared defaults and validation for entity settings from management payloads and programmatic setup
src/…/ServiceBusModels.javaDefines the stored descriptions for queues, topics, subscriptions, and rules
src/…/ServiceBusNamespaceManager.javaCoordinates sidecars, endpoints, topology projection, counts, health, and cleanup
src/…/ServiceBusBrokerStarted.javaDefines the event that links broker readiness to topology restoration
src/…/ArtemisReadinessProbe.javaShows how startup confirms real AMQP and AMQPS broker readiness
src/…/ServiceBusContainerManager.javaDefines boot loading, lazy start, mocked mode, and shutdown
src/…/ServiceBusTopologyLoader.javaApplies declarative topology through the normal management path
src/…/ServiceBusConfigGenerator.javaDefines broker endpoints, static DLQ and CBS nodes, disabled auto-creation, and broker plugins
src/…/ServiceBusCbsResponder.javaProvides the CBS handshake, connection-scoped replies, and reconnect behavior for AMQP clients
src/…/ArtemisPatchVersions.javaDefines the shared version contract for patched resources and the sidecar image
docs/service-bus-artemis-integration.mdExplains the Artemis protocol patches and broker plugins in detail
docs/compatibility-tests.mdExplains client contract coverage for the Service Bus paths
docs/storage-backends.mdExplains how the management description is persisted