java-tutorials/patterns-modules/enterprise-patterns
panos-kakos 428f69a966 [JAVA-18177] Moved server modules to jdk9-and-above profile (#13523)
* [JAVA-18177]  Moved server modules to jdk9-and-above profile

* [JAVA-18177]  Upgraded maven-war-plugin version

* [JAVA-18146]  Moved json-modules to jdk9-and-above profile

* [JAVA-18151]  Moved libraries-data module to jdk9-and-above profile

* [JAVA-18176] Moved saas-modules to jdk9-and-above profile

* [JAVA-18165] Moved patterns-modules to jdk9-and-above profile

* [JAVA-18146] Fixed tests at gson module

* [JAVA-18165] Upgraded maven-war-plugin version

* [JAVA-16377] Moved apache-cxf-module to jdk9-and-above profile + comment out cxf spring

* [JAVA-18151] Testing maven compiler plugin

* [JAVA-18151] Ignored 2 test cases

* [JAVA-18151] import javassist dependency manually

* [JAVA-16377] Upgraded spring version + uncomment cxf-spring module
2023-02-26 21:55:24 +05:30
..
src
test
README.md
pom.xml [JAVA-18177] Moved server modules to jdk9-and-above profile (#13523) 2023-02-26 21:55:24 +05:30

README.md

Wire Tap Pattern

The application shows you how to use a Wire Tap to monitor, debug or troubleshoot messages flowing through the system, without permanently consuming them off, or making any changes to the expected message in the output channel.

This example shows how to implement this with a simple Apache Camel application using Spring Boot and Apache ActiveMq. For convenience, we are using in-memory activeMq.

Configuring and using the Connection Factory

  1. Create CamelContext.
  2. Connect to embedded (or remote) ActiveMQ JMS broker.
  3. Add JMS queue to CamelContext.
  4. Load file orders (xml/csv) from src/data into the JMS queue.
  5. Based on the extension of the incoming file message, route to the respective queues.
  6. Test that the destination route is working.
  7. Audit the received file (order) from the wire tap queue.

How to run the example:

mvn spring-boot:run

The Wire Tap processor, by default, makes a shallow copy of the Camel Exchange instance. The copy of the exchange is sent to the endpoint specified in the wireTap statement. The body of the wire tapped message contains the same object as that in the original message which means any change to the internal state of that object during the wire tap route may also end up changing the main messages body.

To solve this, we need to create a deep copy of the object before passing it to the wire tap destination. Wire Tap EIP provides us with a mechanism to perform a “deep” copy of the message, by implementing the org.apache.camel.Processor class. This needs to be be called using onPrepare statement right after wireTap. For more details, check out the AmqApplicationUnitTest.class.

Relevant Articles: