Shovels are a RabbitMQ feature, and ActiveMQ has no shovel element, so the XML in many guides does not work. To move JMS messages between brokers in a Spring Boot system you configure the brokers themselves: a network connector in ActiveMQ Classic, a bridge in ActiveMQ Artemis, or an explicit forwarding route in Apache Camel. Spring Boot only connects your application to a broker. It does not move messages between brokers.
This article shows each option, when to choose it, and the Spring Boot code that produces and consumes messages on both sides.
A shovel is a RabbitMQ plugin that consumes from a queue on one broker and republishes to an exchange or queue on another. ActiveMQ solves the same problem with different names.
| Need | RabbitMQ | ActiveMQ Classic | ActiveMQ Artemis |
|---|---|---|---|
| Forward queue messages to another broker | Shovel | Network connector with static destinations | Core bridge |
| Share destinations across many brokers | Federation | Network of brokers | Cluster connection |
| Forward from application code | Custom client | Camel route or Spring Integration | Camel route or Spring Integration |
Pick the broker feature when you want forwarding to survive application restarts and to be managed in one place. Pick application-level forwarding when you must transform, filter or enrich messages on the way.
In ActiveMQ Classic, a network connector on the source broker pulls messages for chosen destinations and forwards them to the remote broker. Add it to conf/activemq.xml on the broker that holds the messages:
What the attributes do:
uri lists the remote broker. static: means a fixed address list; failover: can be nested for several remote brokers.duplex="false" forwards in one direction only. With true, messages can flow both ways over one connection.conduitSubscriptions="true" avoids duplicate delivery when several consumers on the remote side subscribe to the same destination.staticallyIncludedDestinations limits forwarding to the destinations you list. Without it, a network connector forwards messages only when a consumer on the remote broker has an interest in the destination.Store the password in a secret store or an encrypted property, not in the XML file you commit.
Artemis uses a core bridge defined in broker.xml. A bridge consumes from a local queue and sends to an address on a remote broker, and it reconnects on its own.
reconnect-attempts set to -1 retries forever. Duplicate detection protects against a message being delivered twice after a reconnect, as long as producers set a duplicate ID or the bridge adds one.
When you must change messages in flight, or the brokers come from different vendors, run a small Spring Boot service with a Camel route. The camel-jms-starter dependency from Camel Spring Boot provides the JMS component.
The two connection factories are beans you define for the source and target broker. The route consumes in a transaction, so the message is acknowledged on the source only after it is sent to the target. A failure leaves it on the source queue for redelivery. For strict exactly-once behaviour across two brokers you need XA transactions, otherwise design the consumer to tolerate duplicates.
Add the starter that matches your broker. Spring Boot 3.x ships spring-boot-starter-activemq for Classic and spring-boot-starter-artemis for Artemis. Check the release notes of your Boot version before upgrading, because broker support changes between major releases.
For ActiveMQ Classic use spring.activemq.broker-url, spring.activemq.user and spring.activemq.password. The producer and consumer are ordinary Spring JMS code, and they do not know about the forwarding:
Run the producer against the source broker and the listener in a second application pointed at the remote broker. Once the connector or bridge is active, a message published on the first broker appears on the second.
No. Shovels belong to RabbitMQ. In ActiveMQ Classic use a network connector, and in Artemis use a bridge.
No. Spring Boot auto-configures the client connection. Forwarding is configured on the broker, or in Camel or Spring Integration code.
Forwarding gives at-least-once delivery, so a duplicate is possible after a failure. Make consumers idempotent, and enable duplicate detection in Artemis.
Use the network connector or bridge for plain forwarding. Use Camel when you need to transform, filter or route to a different vendor.
There is no shovel in ActiveMQ, so use the equivalent feature of your broker: a network connector in Classic, a bridge in Artemis, or a Camel route when messages need processing. Keep Spring Boot code unaware of the forwarding, secure the broker credentials, and test failure and recovery before you rely on the link.