Skip to content

[Enhancement]: Azure Service Bus Custom Config.json #1423

Description

@chasewallis

Problem

It appears as though the current implementation of ServiceBusBuilder doesn't provide a way to customize the service bus configuration. For example, the Java version of TestContainers has an option like:
.withConfig(MountableFile.forClasspathResource("/service-bus-config.json"))

The default configuration provides a single queue, a single topic with 3 subscriptions. The problem I'm having is that those 3 subscriptions have filters on them which prevent the messages I am sending to being picked up by my consumer.

Solution

A solution has already been determined by the Java testcontainers. Add an method called WithConfig to pass in the .json config file.

.withConfig(MountableFile.forClasspathResource("/service-bus-config.json"))

Benefit

Being able to configure the service bus to better match the production service bus would provide tests that better reflect the environment they will run in.

Alternatives

An alternative to providing a file would be to make methods to define the queues/topics. For example:

var serviceBusContainer = new ServiceBusBuilder()
  .WithImage("mcr.microsoft.com/azure-messaging/servicebus-emulator:latest")
  .WithQueue("my-queue", options => {
          // allow cusomtization of the queue
   })
  .WithTopic("my-topic", options => {
     options.WithSubscription("sub1", subOptions => {...})
     options.WithSubscription("sub2", subOptoins => {...})
  })
  .Build();

Would you like to help contributing this enhancement?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions