이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 33. Diverting and Splitting Message Flows


Diverts are objects that transparently divert messages routed to one address to some other address, without making any changes to any client application logic.
Diverts can be exclusive (messages are diverted to the new address and do not go to the previous address at all), or non-exclusive (a copy of the message is sent to the new address, and the original message goes to the old address). Non-exclusive diverts can therefore be used for splitting message flows, for example, when every order sent to an order queue must be monitored.
Diverts can also be configured with a filter, so that only messages that match the filter are diverted.
Diverts can also be configured to apply a Transformer. If specified, all diverted messages can be transformed by this Transformer.
Diverts only move messages to addresses on the same server, but when used in combination with bridges more complex routings can be set up. One common use case to "divert" to a different server is to divert messages to a local store-and-forward queue and then set up a bridge to consume from that queue and forward consumed messages to an address on another server. The diverts on a server can be thought of as a routing table for messages. Combining diverts with bridges allow you to create a distributed network of reliable routing connections between multiple geographically distributed servers.
Diverts are defined in the <JBOSS_HOME>/jboss-as/server/<PROFILE>/deploy/hornetq/hornetq-configuration.xml file. There can be zero or more diverts in the file.

33.1. Exclusive Diverts

An exclusive divert diverts all matching messages that are routed to the old address to the new address. Matching messages do not get routed to the old address.
Diverts are defined in <JBOSS_HOME>/jboss-as/server/<PROFILE>/deploy/hornetq/hornetq-configuration.xml using the following directives:
<divert name="prices-divert">                  
   <address>jms.topic.priceUpdates</address>
   <forwarding-address>jms.queue.priceForwarding</forwarding-address>    
   <filter string="office='New York'"/>
   <transformer-class-name>
    org.hornetq.jms.example.AddForwardingTimeTransformer
   </transformer-class-name>     
   <exclusive>true</exclusive>
</divert>
Copy to Clipboard Toggle word wrap
The prices-divert divert specified above diverts any messages sent to the address jms.topic.priceUpdates (a local JMS Topic called priceUpdates) to another local address jms.queue.priceForwarding (a local JMS Queue called priceForwarding).
A filter string is also specified so that only messages with the message property office='New York' are diverted. All other messages continue to be routed to their usual address. The filter string is optional; if it is not specified, all messages are diverted.
The transformer class is also optional. When specified, transformation is executed for each matching message. This allows you to change the message body or properties before the message is diverted. The example above uses a transformation to add a header recording the time the divert occurred.
As a whole, the above example diverts messages to a local store-and-forward queue, which is configured with a bridge, which forwards the message to an address on another HornetQ server.
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat