18.6. Diverts

download PDF
Diverts are objects configured in HornetQ; which help in diverting messages from one address (to which the message is routed) to some other address. Diverts can be configured in server configuration files (standalone.xml and domain.xml).
Diverts can be classified into the following types:
  • Exclusive Divert: A message is only diverted to a new address and not sent to the old address at all
  • Non-exclusive Divert: A message continues to go the old address, and a copy of it is also sent to the new address. Non-exclusive diverts can be used for splitting the flow of messages
Diverts can be configured to apply a Transformer and an optional message filter. An optional message filter helps only divert messages which match the specified filter. A transformer is used for transforming messages to another form. When a transformer is specified; all diverted messages are transformed by the Transformer.
A divert only diverts a message to an address within the same server. If you need to divert a message to an address on a different server, you can follow the pattern described below:
  • Divert messages to a local store and forward queue. Setup a bridge which consumes from that queue and directs messages to an address on a different server
You can combine diverts with bridges to create various routings.

18.6.1. Exclusive Divert

An exclusive divert; diverts all messages from an old address to a new address. Matching messages are not routed to the old address at all. You can enable exclusive divert by setting exclusive attribute as true in standalone.xml and domain.xml server configuration files.
The following example shows an exclusive divert configured in server configuration file(s):
<divert name="prices-divert">
   <filter string="office='New York'"/>
The following list describes the attributes used in the above example:
  • address: Messages sent to this address are diverted to another address
  • forwarding-address: Messages are diverted to this address from the old address
  • filter-string: Messages which match the filter-string value are diverted. All other messages are routed to the normal address
  • transformer-class-name: If you specify this parameter; it executes transformation for each matching message. This allows you to change a message's body or property before it is diverted
  • exclusive: Used to enable or disable exclusive divert

18.6.2. Non-exclusive Divert

Non-exclusive diverts forward a copy of the original message to the new address. The original message continues to arrive at the old address. You can configure non-exclusive diverts by setting exclusive property as false in standalone.xml and domain.xml server configuration files.
The following example shows a non-exclusive divert:
<divert name="order-divert">
The above example makes a copy of every message sent to jms.queue.orders address and sends it to jms.topic.spyTopic address.
Red Hat logoGithubRedditYoutubeTwitter


Try, buy, & sell


About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.