🎄 Happy Holidays! 🥳

Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.

Happy Holidays!

Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.

TestContainers for Solace PubSub+

giri
giri Member, Administrator, Employee Posts: 116 admin
edited May 24 in PubSub+ Event Broker #1

I am excited to share an update on Testcontainers for Solace PubSub+ module.

For those who have not worked with Testcontainers, let me help you with the introduction

Testcontainers is an open source framework for providing throwaway, lightweight instances of databases, message brokers, web browsers, or just about anything that can run in a Docker container. It simplifies the process of integrating unit tests with external dependencies by allowing you to declare these dependencies directly in the test code. The containers can be used for a single test and then discarded, ensuring a clean test environment with no configuration clashes or dependency issues.

The importance of Testcontainers for developers lies in its ability to create a more reliable and consistent testing environment. By using testcontainers, developers can easily emulate specific versions of software and other dependencies that the application interacts with.

Solace Testcontainers extends the utility of the general Testcontainers framework by providing a way to spin up Solace PubSub+ event broker instances as part of the test environment. For developers working with event-driven architectures, this is particularly crucial because it allows you to test the interactions of your applications with a fully functional message broker in a controlled environment. This integration ensures that developers can test your messaging infrastructure and event-driven workflows thoroughly, catching potential issues early in the development cycle and significantly reducing the risk of bugs in production environments. This capability is especially important for building robust, scalable, and fault-tolerant distributed systems.


A simple 2-line of code can get you a message broker up and running for testing:

var solaceContainer = new SolaceContainer(DockerImageName.parse("solace/solace-pubsub-standard:latest"));
solace.start();


The Solace testcontainer module for Java can be found here Solace PubSub+. For the curious minds that want to look under the hood, the code for this module can be found here. It supports working with the standard protocols supported by Solace broker: AMQP, MQTT, REST, SMF and SMF+SSL.

In conclusion, Testcontainers helps developers gain the ability to automate tests in a consistent and isolated environment, thereby avoiding the "it works on my machine" syndrome and ensuring that their applications are thoroughly tested against a real Solace broker before deployment. This approach not only reduces bugs and deployment risks but also significantly enhances the reliability and scalability of applications in production environments. Hence, leveraging Testcontainers for testing Solace PubSub+ brokers is a prudent choice for developers aiming to build high-quality, event-driven systems.

Would love to hear your take - give it a try and share your feedback!