I have written an example on how to use servicemix to expose and transparently call pojo services with servicemix. When I started with servicemix I had some problems finding informations and sample code on how to implement pojo services. Guillaume gave me the hint to start with the unit tests from the servicemix sources. So this was my starting point.

The example can also be helpful if you want to embed servicemix in your own code and use it as a fault tolerant and flexible remoting technology. I will shortly publish another example that shows exactly how to use clustering and failover.

I would be very interested in your comments about the example.

Best regards

Christian

Pojo Service example
--------------------

This example shows the use of the Jsr181 component to create
services from pojos and call them transparently via a dynamic proxy.

The example shows two ways to do this.

The first way is by setting up servicemix directly in java. This is a great oportunity to get deeper understanding of the wrokings of servicemix as you can debug through the whole
example. You can even debug into the servicemix code and see how it works.

The second way is by configuring servicemix with spring. This is what you probably will do in production. The configuration in spring shows you how to embed servicemix into your existing spring based application.
So servicemix can act like an additional remoting layer for spring.

The third way would be to make a service assembly and deploy it to a servicemix container. This is not shown at the moment. The wsdl first example of the distro show you a similar example that uses this method.

You can find a current version of this example on my site:
http://www.liquid-reality.de/main/projects/servicemix/pojoexample.zip

Requisites
----------

You should have maven installed.
Either Your local repository should contain servicemix if you built the sources of servicemix or you should have configured a repository that contains the maven 3.0.1 packages.

1) Download ActiveMQ

Download the binary for windows from the following site
http://www.activemq.org/site/activemq-410-release.html

2) Extract the zip

3) Start JMS Server
call bin\activemq.bat

You now have a running jms server on your local machine

either start the example in eclipse
-----------------------------------

1) Import the example into eclipse

call "mvn eclipse:eclipse" from the example dir.
Start eclipse
Configure the classpath variable M2_REPO to your local maven repo
Import the Project in eclipse.

2) Start PojoServer
Debug as java application

3) Start PojoClient
Debug as java application

4) Watch the console logs

Compile and install example standalone
--------------------------------------

1) Compile and install the example
mvn install

2)
start "pojoserver.bat"
or
start "pojoserverspring.bat"

3)
start "pojoclient.bat"
or
start "pojoclientspring.bat"

The client should run through and tell you the example completed sucessfully

4) Hint
The example will throw a javax.naming.NoInitialContextException. This does not mean anything is going wrong. I only did not configure the initial context and did not find a way to suppress this message.

See issue (http://issues.apache.org/activemq/browse/SM-739) if you are missing complextypes in your wsdl.


--

Christian Schneider
---
http://www.liquid-reality.de

Reply via email to