Suresh Rohan's Blog

This blog is all about Java, J2EE,Spring, Angular, React JS, NoSQL, Microservices, DevOps, BigData, Tutorials, Tips, Best practice, Interview questions, Views, News, Articles, Techniques, Code Samples, Reference Application and much more

Friday, October 16, 2015

Pattern: Wire Tap


Pattern: Wire Tap

How do you inspect messages that travel on a point-to-point channel?

It can be very useful to see which messages traverse a channel. For example, for simple debugging purposes or to store messages in a Message Store.

You can't just add another listener to the Point-to-Point Channel because it would consume
messages off the channel.

You could also consider changing the channel to a Publish-Subscribe Channel. This would allow
additional listeners to inspect messages without disturbing the flow of messages. However, a
Publish-Subscribe Channel change the semantics of the channel. For example, multiple Competing
Consumers may be consuming messages off the channel, relying on the fact that only one
consumer can receive a specific message.

Insert a simple Recipient List into the channel that publishes each incoming message to the main channel and a secondary channel.


The Wire Tap is a fixed Recipient List with two output channels. It consumes messages off the
input channel and publishes the unmodified message to both output channels. To insert the Wire
Tap into a channel, you need to create an additional channel and change the destination receiver
to consume of the second channel. Because the analysis logic is located inside a second
component, we can insert a generic Wire Tap into any channel without any danger of modifying
the primary channel behavior. This improves reuse and reduces the risk of instrumenting an
existing solution.



No comments:

Post a Comment