This project demonstrates how to use the Service Bus Emulator as a test container.
Content:
- Using Service Bus Emulator - Legal
- Building Service Bus Emulator as Test Container
This Service Bus Emulator test container project is based on the official Service Bus Emulator project.
Azure Service Bus Emulator
depends on (requires) Azure SQL Edge Developer Edition
service.
Azure Service Bus Emulator
is licensed under EMULATOR EULA.
Azure SQL Edge Developer Edition
is licensed under SQL EDGE EULA.
Docker Hub page: https://hub.docker.com/r/microsoft/azure-messaging-servicebus-emulator
To work with emulator read:
- EMULATOR EULA
- AZURE SQL EDGE EULA
- MIT LICENCE
- Accept EULA by setting
ACCEPT_EULA
toY
in src/test/resources/servicebus-emulator.properties file or set as environment variable.
On windows execute:
$>Start-Process powershell -Verb RunAs -ArgumentList 'Set-ExecutionPolicy Bypass –Scope CurrentUser'
Service Bus emulator does not have a Testcontainers module, and additionally the emulator requires Azure SQL Edge
.
There are two ways to initialize the Service Bus Emulator as a test container:
code compose
- Composing through code using the GenericContainer class - AbstractServiceBusContainerCodeComposedocker compose
- Using a Docker Compose file and ComposeContainer class - AbstractServiceBusContainerDockerCompose
In the first case, tests or applications interact directly with the ports exposed by the generic emulator and storage test containers.
In the second case, an additional ambassador
container is created, serving as a proxy to the generic emulator and storage containers.
Code Compose:
Docker Compose:
- Read the legal documents related to using the Service Bus Emulator and Azure SQL Edge Developer Edition
- Accept the
EULA
by settingACCEPT_EULA
toY
in the servicebus-emulator.properties file or set as environment variable. - Set
SQL_PASSWORD
in the servicebus-emulator.properties file or set as environment variable. - Adjust the emulator configuration as needed in the servicebus-emulator-config.json file.
Important:
- The
azure-messaging-servicebus
dependency included inspring-cloud-azure-starter-servicebus v5.19.0
does not support Service Bus emulator connection string and will attempt to use the default AMQP port (5671). To work with the emulator, you need to override this dependency and useazure-messaging-servicebus v7.17.8
. - For
JMS
, you need to build a connection factory with emulator parameters because thejms-servicebus-starter
does not support emulator connection strings.