Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

In

...

this

...

exercise,

...

you

...

will

...

have

...

to INLINE

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

...

You can also use servicemix-camel instead of servicemix-eip to implement the wiretap pattern. Just omit the steps related to tutorial-eip-su and have a look at Replacing tutorial-eip-su with tutorial-camel-su to learn how to do this.

...

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.

Afterwards, add these two new service units to the service assembly by adding the necessary <dependency/>s to the SA's pom.xml. If you want, you can also change the <name/>s to get a cleaner build log.

Configure tutorial-jms-su

Change the tutorial-jms-su's xbean.xml to access a queue named queue/tutorial on ActiveMQ (which is embedded in ServiceMix).

...

Configure tutorial-eip-su

...

Change

...

the

...

tutorial-eip-su

...

's

...

xbean.xml

...

to

...

define

...

the

...

wiretap

...

we

...

need.

...

...

We want to forward the message exchange to the jms endpoint, so we specify that information on the first <eip:exchange-target/>.

...

The

...

second

...

one

...

refers

...

back

...

to

...

the

...

<file:sender/>

...

endpoint

...

we

...

declared

...

earlier.

...

Configure tutorial-file-su

...

You

...

have

...

to

...

change

...

the

...

targetService

...

on

...

the

...

<file:poller

...

/>

...

endpoint

...

to

...

refer

...

to

...

our

...

newly

...

created

...

wiretap.

...

Afterwards,

...

it

...

should

...

like

...

this:

...

...

Build and deploy

When everything is done, you are ready to build and deploy the service assembly. When you do the build, the log should be similar to this one (if the SA isn't built last, you forgot to add the necessary <dependency/> to that pom.xml file):

...

For the deploy,

...

you

...

have

...

two

...

ways

...

:

...

  • you

...

  • can

...

  • deploy

...

  • it

...

  • directly

...

  • using

...

  • the

...

  • JBI

...

  • maven

...

  • plugin

...

  • mvn

...

  • jbi:projectDeploy

...

  • -DforceUpdate=true

...

  • you can create the SA zip file and copy the SA zip file into the SERVICEMIX_HOME/hotdeploy

...

  • directory

...

  • mvn

...

  • install

Testing

If you copy a file into the poller's

...

target

...

directory

...

now,

...

it

...

will

...

also

...

be

...

moved

...

into

...

the

...

sender's

...

directory,

...

just

...

as

...

before.

...

However,

...

there

...

should

...

also

...

be

...

a

...

copy

...

of

...

the

...

message

...

in

...

our

...

JMS

...

queue.

...

To

...

check

...

this,

...

connect

...

to

...

ServiceMix

...

using

...

a

...

JMX

...

console

...

(refer

...

back

...

to

...

our

...

previous

...

tutorial

...

if

...

you

...

need

...

help

...

doing

...

this)

...

and

...

navigate

...

the

...

MBean

...

tree

...

to

...

org.apache.activemq/localhost/Queues

...

.

...

A

...

queue

...

should

...

have

...

been

...

auto-created

...

with

...

the

...

name

...

queue/tutorial

...

and

...

the

...

EnqueueCount

...

attribute

...

is

...

showing

...

the

...

number

...

of

...

messages

...

that

...

have

...

already

...

been

...

sent

...

(in

...

our

...

case:

...

1).

...


Image Added

Things to remember

  • More advanced Maven archetypes already create a sample xbean.xml file and add the necessary JBI component dependency to the pom.xml
  • Adding SU to an existing SA is as simple as adding <dependency/>s to the SA's pom.xml
  • To update a service assembly already deployed on servicemix, you need to use the mvn jbi:projectDeploy -DforceUpdate=true command or to create the new SA zip file using mvn install and copy the zip file into the SERVICEMIX_HOME/hotdeploy directory

Further reading

  • servicemix-jms provides more information on the configuration options we used for tutorial-jms-su
  • servicemix-eip gives you more details about the wire tap EIP, as well as all the other patterns that are supported by ServiceMix



...