To configure JMS federation for cross-region messaging in Spring Boot, federate the brokers, not the application: configure ActiveMQ Artemis federation (or a bridge) between the regional brokers in broker.xml, and let each Spring Boot service connect only to its local broker with a normal JmsTemplate and @JmsListener. Federation pulls or pushes messages between independent brokers over a wide-area link, so regions keep working when the link is slow or down.
The earlier version of this answer used an ActiveMQ Classic networkConnector with an invalid filter element. This article shows the current Artemis approach, then the Classic network connector done correctly.
| Feature | Link type | Best for |
|---|---|---|
| Cluster | Tightly coupled brokers, shared topology | One data centre, low latency |
| Federation | Loosely coupled, one-way or two-way, demand based | Several regions, unreliable or slow links |
| Core bridge | Fixed forwarding from one address to another | Simple, explicit one-way copy of a queue |
Clusters assume a fast, reliable network and a common set of brokers. Across regions that assumption breaks, which is why federation exists. It also keeps a regional outage from stalling the other region.
Federation links an upstream broker to a downstream broker. The downstream broker connects out to the upstream one, so only one direction of firewall rule is needed. Two policy types decide what moves:
On the broker in the region that should receive messages (the downstream), define a connector to the other region and a federation:
Notes on the configuration:
orders.# is Artemis wildcard syntax: # matches any number of words and * matches one word.<transformer-ref> or max-hops settings if you chain more than two regions, otherwise messages can loop.Element and attribute names can differ slightly between Artemis releases, so check the federation chapter for your installed version.
Because federation lives in the brokers, the application stays simple. Each region runs the same code and talks to its own broker:
With Spring Boot 3 and later, the JMS API is jakarta.jms. If you need the region in the message, add a message property (for example region) in a MessagePostProcessor and filter with a selector on the consumer side.
ssl connector (tcp://...?sslEnabled=true) and a truststore.In ActiveMQ Classic, cross-region forwarding is done with a network connector. A correct, duplex example that only forwards the destinations you list:
Classic uses > as its recursive wildcard. A networkConnector must contain include or exclude elements directly, as above, not a free-form filter block.
No. Federation is a broker feature. Spring Boot only configures the connection to the local broker. Keep the federation settings in broker.xml or your broker deployment.
A bridge forwards every message from a source address to a target, always. Federation is demand driven: queue federation moves messages only when a consumer is waiting, which reduces wasted traffic across regions.
No. Expect at-least-once delivery and design consumers to tolerate duplicates.
No. RabbitMQ has its own Federation and Shovel plugins, used through AMQP and Spring AMQP, not through JMS.
Federate the brokers, keep Spring Boot connected only to its local broker, and treat cross-region delivery as at-least-once. Use Artemis queue and address policies in broker.xml, secure the link with TLS and a dedicated user, and monitor the link. In ActiveMQ Classic, use a duplex networkConnector with explicit included destinations.