Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this exercise, you will have to

Excerpt

add two service units and redeploy the service assembly by yourself

.

Introduction

Instead of simply copying files from one directory to the other, we are now going to send the message straight to a JMS queue. We also want to retain a copy of the original message for archiving, so we are going to use the wiretap pattern for that.

Creating the projects

First of all, we have to create two additional project modules for our two new service units. Instead of using the plain servicemix-service-unit archetype as before, we are now going to use two new archetypes:

  • servicemix-eip-service-unit to create module tutorial-eip-su
  • servicemix-jms-provider-service-unit to create tutorial-jms-su

Check this page if you need help in running the archetype. These archetypes are a bit more advanced:

  • they already add the required <dependency/> for the JBI component they target
  • they provide you with a sample xbean.xml to start from.

Configure tutorial-eip-su

Change the tutorial-eip-su's xbean.xml to define the wiretap we need. Have a look at servicemix-eip#WireTap for more information about how to configure it.

Code Block
xml
xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:eip="http://servicemix.apache.org/eip/1.0"
       xmlns:tut="urn:servicemix:tutorial">

  <eip:wire-tap service="tut:wiretap" endpoint="endpoint">
    <eip:target>
      <eip:exchange-target service="tut:jms" />
    </eip:target>

    <eip:inListener>
      <eip:exchange-target service="tut:file" endpoint="sender" />
    </eip:inListener>
  </eip:wire-tap>

</beans>

We want to forward the message exchange to the jms endpoint, while sending a copy back to the file sender endpoint we previously declared.