An Azure service that provides cloud messaging as a service and hybrid integration.
Use a pure asynchronous request-reply pattern and remove the requirement to hold the HTTP connection open. That keeps the gateway stateless and avoids Service Bus session limits entirely.
Key elements:
- Decouple HTTP request from worker reply
- Front-end gateway:
- Validates the request.
- Enqueues a command message to Service Bus (no session required).
- Immediately returns
202 Acceptedwith a URL to a status resource in theLocationheader.
- This follows the Asynchronous Request-Reply pattern with HTTP polling, where the client no longer waits synchronously for the worker to complete.
- Front-end gateway:
- Use an HTTP status endpoint instead of in-memory correlation
- The
Locationheader points to a status endpoint, for example/operations/{operationId}. - The gateway persists operation state in a durable store (cache/DB) keyed by
operationId, not in process memory. - Any gateway pod can handle
GET /operations/{operationId}because all state is externalized. - While work is in progress, the status endpoint returns
200 OKwith a body indicating the current state. - When work completes, the status endpoint either:
- Returns the result directly, or
- Returns
303 See Otherredirecting to the final resource URL.
- The
- Correlate via IDs, not Service Bus sessions
- Include a correlation/operation ID in the command message sent to Service Bus.
- The worker processes the message asynchronously and publishes a completion message or writes the result directly to the status store using that ID.
- No Service Bus sessions are required; correlation is done at the application level via the ID.
- Make the gateway and workers fully stateless
- Gateway pods:
- Only send messages to Service Bus and read/write operation state from a shared store.
- Do not hold open HTTP connections waiting for Service Bus replies.
- Workers:
- Consume from Service Bus using standard queues/topics.
- Write results and state transitions to the shared store.
- This aligns with asynchronous messaging guidance where services scale independently and failures in downstream services do not block the front end.
- Gateway pods:
- Apply asynchronous messaging patterns for scale
- Use queues and the Queue-Based Load Leveling and Competing Consumers patterns so workers can scale horizontally and process messages at their own rate.
- Ensure message processing is idempotent so retries do not corrupt state.
- Use Service Bus built-in retry and dead-letter capabilities for robustness.
- Manage client experience
- Since operations are long-running (45+ seconds), design the UX around asynchronous completion:
- Show “in progress” state based on the status endpoint.
- Optionally send notifications (email, push, webhook) when the operation completes.
- Since operations are long-running (45+ seconds), design the UX around asynchronous completion:
This architecture:
- Eliminates the need for Service Bus sessions and their concurrency limits.
- Keeps gateway pods stateless and horizontally scalable.
- Avoids stateful routing and session lock issues because no HTTP connection is tied to a specific worker or queue consumer.
References: