I am writing a spring-boot application that should receive and send JMS messages. The address, port, login and password to connect to the broker are read from configs. Initially, I do not know what type of broker to work with. Is there a universal JMS client for working with any brokers? I shoveled Google and, as I understood, for each broker (ActiveMQ, RabbitMQ, IBM MQ) there is a client implementation. Or am I misunderstanding something?
2 answers
If you follow the JMS specification and do not use various extensions and improvements from specific brokers, then your code should work with any of them. But the set of libraries (drivers) for each broker should be different.
There is no universal JMS client, but it is possible not to rewrite the code for each provider. When implemented correctly, it should work as follows.
JMS is an API, in its composition mainly interfaces that have no implementation. Thus, the code that uses the JMS API works with abstractions that are not initially implemented (and therefore unworkable).
The implementation is in the JMS libraries shipped with a specific broker - each product has its own implementation. To make everything work, you need:
- Add broker libraries to your application
- Configure the application so that it accesses the queues on the broker's server.
You can write basic business logic that works with interfaces, and this part should not change. Most likely, the configuration will be the most difficult task, and it may turn out that for each broker it will have to be solved differently. The main goal is to create objects that implement JMS interfaces (such as connection factory, sessions, queues, etc.). How to do it - a separate large topic, most likely, will have to read the documentation regarding integration through JMS for each broker.
An alternative option is to look for ready-made solutions of a higher level (compared to brokers), for example, integration platforms that already have support from different brokers.