Skip to content

Declare a Service Bus queue Azure accepts in the Java Terraform sample - #129

Merged
paolosalvatori merged 1 commit into
mainfrom
fix-servicebus-java-terraform-queue
Oct 13, 2026
Merged

paolosalvatori merged 1 commit into
mainfrom
fix-servicebus-java-terraform-queue

Conversation

@paolosalvatori

@paolosalvatori paolosalvatori commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

The Terraform variant of the servicebus/java sample declares a Service Bus queue that Azure does not accept, and an app that could not use it if it did.

  • The queue is partitioned, express and duplicate-detecting. Azure refuses that combination: "Both DelayedPersistence and RequiresDuplicateDetection property can't be enabled together. Entities with Duplicate detection enabled on them must be persistent, so persistence can't be delayed." (Service Bus Resource Manager exceptions). A queue with these three settings created through the Service Bus management API on 2026-10-12 got exactly that MessagingGatewayBadRequest.
  • The queue also requires sessions, while the Spring Boot app sends and receives without a session ID: "When you enable sessions on a queue or a subscription, client applications can no longer send or receive regular messages" (Message sessions).

The sample only ran because the emulator accepted any queue. With localstack-pro#9364 the Service Bus emulator validates queues and enforces sessions as Azure does, so terraform apply now fails on this queue with Azure's error.

Fixes SMF-938
Related SMF-865

Changes

  • samples/servicebus/java/terraform/variables.tf: servicebus_queue_express_enabled and servicebus_queue_requires_session default to false, like the queue of the Azure CLI and Bicep variants of the sample. Duplicate detection and partitioning stay on: Azure accepts them together.

Tests

  • On an emulator image built from localstack-pro#9364, the sample's terraform/deploy.sh provisions the queue and the app prints Received message from Azure Service Bus: Hello, World!, with LS_AZURE_ENFORCE_RBAC off and on. Before this change the same image refuses the queue with MessagingGatewayBadRequest.
  • On Azure, a Standard namespace accepts a queue that is partitioned, duplicate-detecting and session-enabled and refuses it once it is also express (probed on 2026-10-12); this change turns off both express and sessions.
  • The Azure CLI and Bicep variants of the sample are unchanged and pass on the same image.

🤖 Generated with Claude Code

The Terraform variant of the servicebus/java sample created a queue that is partitioned, express and duplicate-detecting, which Azure refuses ("Both DelayedPersistence and RequiresDuplicateDetection property can't be enabled together", Service Bus Resource Manager exceptions), and that requires sessions, while the Spring Boot app sends and receives without a session ID ("When you enable sessions on a queue or a subscription, client applications can no longer send or receive regular messages", Message sessions). The queue now defaults to express and sessions off, like the Azure CLI and Bicep variants of the sample.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paolosalvatori
paolosalvatori requested a review from a team as a code owner October 13, 2026 03:11
Copilot AI balanced review requested due to automatic review settings October 13, 2026 03:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The defaults now match Azure constraints and the application’s messaging behavior.

0 open findings

What changed in this PR

Updates the Java Service Bus Terraform sample to provision an Azure-compatible queue usable by its non-session-aware application.

Changes:

  • Disables sessions by default.
  • Disables express entities to remain compatible with duplicate detection.
File Description
samples/​servicebus/​java/​terraform/​variables.tf Sets Azure-compatible queue defaults.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@paolosalvatori
paolosalvatori merged commit 44657a5 into main Oct 13, 2026
5 of 8 checks passed

This branch had an error being deployed

1 failed deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants