Skip to content

A Spring Boot project demonstrating the use of an Azure Service Bus emulator as a test container.

License

Notifications You must be signed in to change notification settings

mirkoiv/servicebus-emulator-as-testcontainer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using Service Bus Emulator as a Test Container

This project demonstrates how to use the Service Bus Emulator as a test container.

Content:

  1. Using Service Bus Emulator - Legal
  2. Building Service Bus Emulator as Test Container

Using Service Bus Emulator - Legal

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:

On windows execute:

$>Start-Process powershell -Verb RunAs -ArgumentList 'Set-ExecutionPolicy Bypass –Scope CurrentUser'

Building Service Bus emulator as a Test Container

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:

  1. code compose - Composing through code using the GenericContainer class - AbstractServiceBusContainerCodeCompose
  2. docker compose - Using a Docker Compose file and ComposeContainer class - AbstractServiceBusContainerDockerCompose

Key Differences Between the Two Approaches

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:

servicebus emulator as test container code compose structure

Docker Compose:

servicebus emulator as test container docker compose structure

Setup

  1. Read the legal documents related to using the Service Bus Emulator and Azure SQL Edge Developer Edition
  2. Accept the EULA by setting ACCEPT_EULA to Y in the servicebus-emulator.properties file or set as environment variable.
  3. Set SQL_PASSWORD in the servicebus-emulator.properties file or set as environment variable.
  4. Adjust the emulator configuration as needed in the servicebus-emulator-config.json file.

Important:

  1. The azure-messaging-servicebus dependency included in spring-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 use azure-messaging-servicebus v7.17.8 .
  2. For JMS, you need to build a connection factory with emulator parameters because the jms-servicebus-starter does not support emulator connection strings.

Resources

About

A Spring Boot project demonstrating the use of an Azure Service Bus emulator as a test container.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages