Quick revision
The short answer
We would evaluate three options: run the same commercial broker in the cloud, move to a managed broker that still speaks JMS, or move the applications to a different messaging model such as Kafka or a cloud-native queue. Keeping the JMS API limits code changes, while changing the model means redesign and testing, and features like XA transactions, message selectors and ordering assumptions rule some options out. We would sequence the work by business risk and coupling, bridge old and new brokers so each application moves on its own schedule, and compare licence and support costs over several years, not just the first one.
What to remember
In this answer, we planned the move of legacy JMS applications to the cloud. We inventoried what each application depends on, compared running the same broker in the cloud, a managed JMS-compatible broker, and a new messaging model, and saw how XA, selectors and ordering narrow the choice. We sequenced the work by risk and coupling with bridges between brokers so each application moves on its own, and compared costs over several years rather than one.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
We would evaluate three options: run the same commercial broker in the cloud, move to a managed broker that still speaks JMS, or move the applications to a different messaging model such as Kafka or a cloud-native queue. Keeping the JMS API limits code changes, while changing the model means redesign and testing, and features like XA transactions, message selectors and ordering assumptions rule some options out. We would sequence the work by business risk and coupling, bridge old and new brokers so each application moves on its own schedule, and compare licence and support costs over several years, not just the first one.
Background to this question
Messaging is often the last part of a legacy estate to move to the cloud, because many applications share one broker and nobody wants to move them all on one weekend. The question tests whether we can turn a vague goal, moving to the cloud, into options with real costs and an order of work that never stops the business. In this answer, we will recap what ties a JMS application to its broker, compare the three options, look at the features that narrow the choice, and then plan the sequence with bridges and a multi-year cost comparison.
1A Quick Recap: What Ties an Application to Its Broker
JMS, now Jakarta Messaging, is an API, not a wire protocol. The application codes against interfaces such as ConnectionFactory, Session and MessageProducer, and a client library from the broker vendor implements them. In theory, swapping the broker means swapping the client jar and the connection settings. In practice, applications also depend on the broker's behaviour: how it orders messages, which selectors it supports, whether it takes part in XA transactions, how it redelivers, and vendor extensions such as message groups.
So the first job is to find out which applications depend on what. For each one we record the destinations it uses, whether it uses XA (two-phase commit with a database, coordinated by a transaction manager), message selectors (SQL-like filters such as region = 'EU' that a consumer applies on the broker), ordering expectations, message sizes and volumes, and who owns it.
2The Three Options and What Each Costs
The options differ mainly in how much code changes and how much of the broker we still operate ourselves.
| Option | Code change | Operations | Main risk |
|---|---|---|---|
| Same broker, cloud hosted | connection settings | still ours | licence cost stays |
| Managed JMS-compatible broker | client library, config | mostly the provider's | partial JMS feature support |
| Different model (Kafka, cloud queue) | redesign and retest | managed or ours | semantic changes, effort |
Running the same broker in the cloud, on virtual machines or containers, keeps behaviour identical and needs almost no code changes, but we keep operating it and keep paying its licence. A managed JMS-compatible broker, such as a cloud provider's managed ActiveMQ or a service that supports JMS over AMQP, removes most of the operations work, but its JMS support may be partial, so every feature the inventory found must be checked against the service's documentation. Moving to another model, for example Kafka for event streams or a cloud queue service for work queues, can be the best long-term fit for some applications, but it is a redesign: delivery semantics change, so the code and its tests change too.
Notice that the choice does not have to be the same for every application. A common result is that most applications move to a managed JMS broker, a few critical XA users stay on the commercial broker for now, and a few event-heavy ones are redesigned onto Kafka.
3Features That Narrow the Choice
Three features usually decide where an application can go. XA transactions are the strongest constraint: many managed services do not take part in XA at all, so an application that commits a message and a database row atomically either stays on a broker that supports XA or is changed to use local transactions with an idempotent consumer. That change is worth making, but it is a code change with testing.
Message selectors are the second. A consumer that filters with JMSType = 'refund' depends on the broker evaluating selectors efficiently. Some services support only part of the selector syntax or none, and in Kafka there is no broker-side filtering at all, so the filter would move into the consumer or into separate topics. The third is ordering: an application that relies on a single queue delivering strictly in order, or on message groups (JMSXGroupID) to keep one customer's messages in sequence, needs an equivalent in the target, such as a Kafka partition key.
A simple search of the code for these patterns, plus the broker's own configuration, gives a list of which applications are easy movers and which are hard.
4Sequencing the Work With Bridges
Moving everything at once is the riskiest plan, because producers and consumers of the same queue would all have to switch on one night. Instead, we connect the old broker and the new one with a bridge: a component that consumes from a destination on one broker and publishes to the same destination on the other. Most brokers have their own bridging (for example core bridges in ActiveMQ Artemis, channels in IBM MQ), and a small Spring or Apache Camel application can do it otherwise.
With a bridge in place, a consumer can move to the new broker while its producers still publish to the old one, and producers can move later. Each application moves independently, and rolling back means pointing it at the old broker again.
- Inventory featuresXA, selectors, ordering, volume
- Pick its targetsame broker, managed JMS, or new model
- Bridge its destinationsold and new broker in sync
- Move consumers, then producersone application at a time
- Stable for two weeks?YesRemove its bridgeNoPoint it back at the old broker
5 steps in order. Play them, or step through them one at a time.
We order the moves by business risk and coupling. Low-risk, loosely coupled applications go first, so the team learns the new platform on something that will not hurt. Applications that share many destinations move together as a group, or wait until their neighbours have moved. The most critical ones, such as payments, go last, when the bridges and the runbooks have been tested many times.
5Comparing Costs Over Several Years
The first-year comparison is misleading. A managed service may look cheaper than a commercial licence, but we should compare five years: licences and support contracts, cloud infrastructure, operations staff time, migration effort, and the cost of running both brokers during the transition. For example, a licence of 400,000 a year plus two engineers to operate the broker can be set against a managed service of 150,000 a year plus a one-time migration of 30 engineer-months. The numbers change the answer from company to company, which is exactly why we write them down. We also check when the current licence renews, because that date often sets the real deadline.
6Follow-up questions
Why not move every application to Kafka while we are at it?
Because a migration that changes the platform and the messaging model at the same time doubles the risk. Kafka is a log, not a queue: no per-message acknowledgement, no selectors, different ordering and retry behaviour. Applications that benefit, such as event streams with many consumers, can be redesigned deliberately; the rest are moved with minimal change first.
What if an application cannot give up XA?
We first ask whether it really needs it. Most XA uses can be replaced with a local transaction and an idempotent consumer that records processed message ids. If it truly cannot change soon, it stays on a broker that supports XA, either the same commercial broker in the cloud or one we operate, and we plan its redesign separately.
How do we know a migrated application is behaving correctly?
We compare counts and lags on both brokers during the bridge period, watch dead-letter queues, and run reconciliation for business-critical flows, such as comparing orders sent with orders received per hour. Any difference is investigated before the bridge is removed.
7Conclusion
In this answer, we planned the move of legacy JMS applications to the cloud. We inventoried what each application depends on, compared running the same broker in the cloud, a managed JMS-compatible broker, and a new messaging model, and saw how XA, selectors and ordering narrow the choice. We sequenced the work by risk and coupling with bridges between brokers so each application moves on its own, and compared costs over several years rather than one.
Open with
I'd start with an inventory, because JMS is only an API and the real ties are behaviour: which applications use XA, message selectors, ordering or message groups, what volumes they have and who owns them.
Then, if they want more
Then I'd evaluate three options per application. The first is running the same commercial broker in the cloud, which needs almost no code change but keeps the licence and the operations work. The second is a managed JMS-compatible broker, which removes most operations but may support only part of JMS, so I'd check every feature we found.
The third is moving to another model like Kafka or a cloud queue, which can fit event-heavy applications better but is a redesign with new tests. XA is usually the deciding constraint, since many managed services don't take part in it; where possible I'd replace it with local transactions and idempotent consumers.
For the sequence, I'd never move everything at once. I'd bridge the old and new brokers so consumers and producers of a destination can move separately, start with low-risk, loosely coupled applications, and leave payments and other critical flows until the bridges and runbooks are proven.
Finally I'd compare five-year costs, licence, support, cloud spend, staff and the migration itself, and check the licence renewal date, since that often sets the real deadline.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- RabbitMQ documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Many legacy Java applications in your company use JMS with a commercial broker on...": https://scrivio-interview-library.netlify.app/spring-boot/rabbitmq-and-jms/bdcfcfee9b/