Versions Compared

Key

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

...

In the case of the Hello World SE, we're lucky that there are no configuration options really, so all we need to do is create SU that depends on the Hello World SE and deploy that. To do this, use the command below:

Panel

$ cd ..
$ mvn archetype:create \
-DarchetypeGroupId=org.apache.servicemix.tooling \
-DarchetypeArtifactId=servicemix-service-unit \
-DarchetypeVersion=3.1-incubating \
-DgroupId=org.apache.servicemix.samples.helloworld.se \
-DartifactId=hello-world-su \
-DremoteRepositories=http://people.apache.org/repo/m2-incubating-repository

This creates a directory named hello-world-su. Now edit the hello-world-su/pom.xml file to add the following dependency on the Hello World SE:

panel
Code Block
xml
xml

<dependency>


  <groupId>org.apache.servicemix.samples.helloworld.se</groupId>


  <artifactId>hello-world-se</artifactId>


  <version>1.0-SNAPSHOT</version>


</dependency>

This tells Maven that the hello-world-su project depends upon the hello-world-se project. After compiling the hello-world-su, copy the JAR file to the ServiceMix deploy directory. As long as it starts up without error, you're ready to begin sending messages to it.

...

Create a file hello-world-su/src/main/resources/xbean.xml with the following contents:

Code Block
xml
xml
<beans xmlns:hwse="http://org.apache.servicemix.samples.helloworld.se/1.0" 
       xmlns:xyz="http://companyxyz.com">
  <hwse:endpoint service="xyz:helloWorld" endpoint="helloWorld"/>
</beans>

...

Code Block
$ mvn archetype:create \
-DarchetypeGroupId=org.apache.servicemix.tooling \
-DarchetypeArtifactId=servicemix-http-consumer-service-unit \
-DarchetypeVersion=3.1-incubating \
-DgroupId=org.apache.servicemix.samples.helloworld.se \
-DartifactId=hello-world-bchttp-su \
-DremoteRepositories=http://people.apache.org/repo/m2-incubating-repository

There should now be a hello-world-bc-su directory under hello-world-smx.

Configure hello-world-

...

http-su

Create configuration for http binding component in hello-world-bchttp-su/src/main/resources/xbean.xml

Code Block
xml
xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:http="http://servicemix.apache.org/http/1.0"
       xmlns:hwse="http://org.apache.servicemix.samples.helloworld.se/1.0"
       xmlns:xyz="http://companyxyz.com">

	<!--  Define an additional classpath location
	      for wsdl resources -->
    <classpath>
        <location>.</location>
    </classpath>

    <http:endpoint service="xyz:helloWorld"
                   endpoint="helloWorld"
                   role="consumer" 
                   locationURI="http://localhost:8192/Service/"
                   defaultMep="http://www.w3.org/2004/08/wsdl/in-out" />	   
</beans>
Info

TODO: explain

Create a service assembly to

...

wrap all of the

...

SUs

Code Blockpanel

$

mvn

archetype:create

\


-DarchetypeGroupId=org.apache.servicemix.tooling

\


-DarchetypeArtifactId=servicemix-service-assembly

\


-DarchetypeVersion=3.1-incubating

\


-DgroupId=org.apache.servicemix.samples.helloworld.se

\


-DartifactId=hello-world-sa

\


-DremoteRepositories=http://people.apache.org/repo/m2-incubating-repository

Image Added

There should now be a hello-world-sa directory under hello-world-smx.

Add the following dependencies to hello-world-sa/pom.xml

Code Block
xml
xml
<dependency>
  <groupId>org.apache.servicemix.samples.helloworld.se</groupId>
  <artifactId>hello-world-su</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
  <groupId>org.apache.servicemix.samples.helloworld.se</groupId>
  <artifactId>hello-world-bchttp-su</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>

Build and Deploy the SA

The easiest way to build all the projects is to create a top level POM file that will tell Maven to build everything for you. The following section describes how to do this. This is a work in progress

Incorporating the Projects Into a Top Level POM

Now that we have created the SU and SA projects, a top level pom.xml must be manually created and made aware of each subproject. This will allow all the projects to be built automatically without having to build each project in order manually. Maven will discover all the projects and build them in the proper order. In the hello-world-smx directory, create a file named pom.xml containing the following content:

Code Block
xml
xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>org.apache.servicemix.samples.helloworld</groupId>
  <artifactId>hello-world-smx</artifactId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Hello World JBI Component</name>

  <modules>
    <module>hello-world-sa</module>
    <module>hello-world-su</module>
    <module>hello-world-bchttp-su</module>
    <module>hello-world-se</module>
  </modules>

</project>

This POM will allow the example to be easily folded in to the ServiceMix samples. The <modules> element denotes the other projects that were created above using the Maven archetypes. Once the pom.xml file from above is saved into the hello-world-smx directory, you should now see the following:

Code Block
$ ls 
hello-world-bchttp-su  hello-world-sa  hello-world-se  hello-world-su  pom.xml

...

As long as you see the BUILD SUCCESSFUL message in the output continue to the next section to give each project a unique name.

Give Each of the Maven Subprojects a Name

Notice in the output above that there are a two projects named A custom project. This is because the archetypes create projects with this generic name. Let's give each project a unique name via each component's pom.xml file. This name will allow Maven's output to denote a component's name in its output making our development work a bit easier. To name each project, simply edit each pom.xml and replace <name>A custom project</name> with an appropriate name. Below are the instructions for naming each component's project:

...

Now when the projects are built you will no longer see a project named A custom project. Instead you'll now see Hello World SE Service Unit and Hello World Service Assembly. Rebuild the projects again using the mvn clean install command on the command-line to see the change.

Deploying the Component and the SU

Now that the SA is built, we're ready to deploy it the Hello World SE, the dependency components and the Hello World SA to the JBI container.

Code Block
$ cp hello-world-se/target/hello-world-se-1.0-SNAPSHOT-installer.zip $SERVICEMIX_HOME/install/
$ cp $SERVICEMIX_HOME/components/servicemix-shared-3.1-incubating-installer.zip $SERVICEMIX_HOME/install/
$ cp $SERVICEMIX_HOME/components/servicemix-http-3.1-incubating-installer.zip $SERVICEMIX_HOME/install/

$ cp hello-world-sa/target/hello-world-sa-1.0-SNAPSHOT.jar $SERVICEMIX_HOME/deploy/

This is a work in progress. I will finish this up very soon.

End-to-End Testing

  1. Save http://svn.apache.org/viewvc/incubator/servicemix/trunk/samples/bridge/client.html to your local desktop and then open it in your browser.
  2. Set Target to http://localhost:8192/Service/Image Removed
  3. Click Send
Note
titleDeploying Component Dependencies

When working with the jbi:projectDeploy you may want to disable dependency deployment. When deploying to a server which has other components sharing these dependencies, they can cause problems during deployment. To stop the Maven JBI plugin from undeploying and redeploying dependencies each time, alter its configuration by disabling the deployment of dependencies using the following:

Code Block

<build>
<plugins>
  <plugin>
    <artifactId>jbi-maven-plugin</artifactId>
    <configuration>
      <deployDependencies>false</deployDependencies>
    </configuration>
  </plugin>
</plugins>
</build>

The configuration above introduces the deployDependencies element to the Maven JBI plugin and sets it to false.

For a few more configurable options on the Maven JBI plugin, see also Ability to configure jbi:projectDeploy goal to exclude updating dependencies.

...

titleTODO

The default implementation of the component accepts InOut MEPs (ADD
LINK TO FURTHER READING CONCERNING MEPs) and return the input content
as the out message. This is already nearly what we want.

OUTLINE for further work:

  • Get Messages
  • read Messages
  • Wiki Markup
    count the bytes
    Maybe easiest by XSLT endpoint (can be used to apply an XSLT stylesheet to the incoming exchange and will return the transformed result as the output message.) see \[ servicemix-saxon\|servicemix-saxon\]
  • send a message back
  • Configure SA so that the example receives messages
    create & populate
    C:\hello-world-SE-SA\hello-world\src\main\resources\servicemix.xml
  • as MyDeployer extends AbstractXBeanDeployer create xbean.xml for SU
  • make something send messages (eg quartz timer, HTTP POST,...) and dump the answer (eg TraceComponent, FireWriter, EIP,...)
  • add a chapter what user may do now / "how to continue when having the working example"

Classpath for SU to include manually till v3.1, see mail

manually editing http://goopen.org/confluence/display/SM/Working+with+Service+Units
manually editing http://www.servicemix.org/site/working-with-service-assemblies.html
use the SU archetype like in http://www.servicemix.org/site/creating-a-protocol-bridge.html
use the SA archetype like in http://www.servicemix.org/site/creating-a-protocol-bridge.html

INS When to use this JBI Component
INS Using the component that you created

provide exact position in the SVN!
/samples/hello-world-SE-SA/
integrate from SVN source like it is done at Configuration at http://www.servicemix.org/site/visualisation.html

maybe moving the content of overlapping existing docus to this new tut and - where appropriate - delete the old ones (only leaving a redirect).
http://www.servicemix.org/site/notes-on-creating-jbi-component-using-maven2.html version14
http://www.servicemix.org/site/creating-a-standard-jbi-component.html version26
are already fully incorporated in the mentioned versions, so delete content and point from there to here (and delete note at the very top)

This shall already include everything stated at
http://www.servicemix.org/site/maven-jbi-plugin.html#MavenJBIplugin-GettingStarted
and
http://www.servicemix.org/site/working-with-components.html

...

This is a work in progress

Additional Resources