Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: INS further explanation/help

...

Warning
titleTODO

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

provide exact position in the SVN!
/samples/hello-world-SE-SU-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
http://www.servicemix.org/site/creating-a-standard-jbi-component.html
is already fully incorporated, so delete content and point from there to here provide additional reading

Maybe add testing

Prerequisites

The following is required:

  • Around 15 minutes of time
  • A running copy of ServiceMix 3.0 and Maven 2.0.4 or higher
  • A connection to the Internet to download dependencies
  • A text editor to alter XML files
  • An editor or IDE for Java files

Overview SE-SU-SA

JBI components are can be tought of as the "smallest applications" you can access in an ESB. They have a very specific purpose, thus a narrow scope and set of functionallity. Components come in two flavours: Service Engine (SE) and Binding Components (BC).

Components are enriched by metadata (which?) and the whole is packed into a Service Unit (SU) - basically a JAR archive.

Several SUs are packed into a Service Assambly (SA). An SA is a complete "application" consisting of multiple components (reminder: the "smallest appliactions") interacting with each other and making up the big "application".

Further reading: JSR 208

Creating the SE

Creating the stub of the SE

First, a JBI component has to be created. Here, we use archetypes, just like shown at Creating a Standard JBI Component and Notes on Creating JBI Component using maven2 and Creating a protocol bridge. The Maven 2 archetypes are a kind of pattern, generic model, blueprint or template, or as Merriam-Webster defines "the original pattern or model of which all things of the same type are representations or copies". Using archetypes, Maven creates the basis for components, settings and so on, thus archetypes spare developers repetetive work and avoid errors like typos etc.

Note: As this text describes how to create a "Hello World" Service Engine and pack it into an SU and SA, the project name is hello-world-SE-SU-SA and the single pieces are named analogous. For a custom project, the IDs and names shall be altered such that they describe the purpose or function of the given piece of the SA.

ServiceMix can be used as a protocol bridge. The following tutorial will explain how to create a JBI Service Assembly (aka a JBI application) to bridge two different protocols. In this example, we will bridge the HTTP/SOAP with the JMS protocol using an InOnly MEP. We will also put between the two protocols an XSLT transformation.
We will leverage ServiceMix archetypes and maven plugin (see Maven JBI plugin).

provide additional reading
Creating a protocol bridge.for a "bigger" example

Maybe add testing

Prerequisites

The following is required:

  • Around 15 minutes of time
  • A running copy of ServiceMix 3.0 and Maven 2.0.4 or higher
  • A connection to the Internet to download dependencies
  • A text editor to alter XML files
  • An editor or IDE for Java files

Overview SE-SU-SA

JBI components are can be tought of as the "smallest applications" you can access in an ESB. They have a very specific purpose, thus a narrow scope and set of functionallity. Components come in two flavours: Service Engine (SE) and Binding Components (BC).

Components are enriched by metadata (which?) and the whole is packed into a Service Unit (SU) - basically a JAR archive.

Several SUs are packed into a Service Assambly (SA). An SA is a complete "application" consisting of multiple components (reminder: the "smallest appliactions") interacting with each other and making up the big "application".

Further reading: JSR 208

Creating the SE

Creating the stub of the SE

First, a JBI component has to be created. Here, we use archetypes, just like shown at Creating a Standard JBI Component and Notes on Creating JBI Component using maven2 and Creating a protocol bridge. The Maven 2 archetypes are a kind of pattern, generic model, blueprint or template, or as Merriam-Webster defines "the original pattern or model of which all things of the same type are representations or copies". Using archetypes, Maven creates the basis for components, settings and so on, thus archetypes spare developers repetetive work and avoid errors like typos etc.

Note: As this text describes how to create a "Hello World" Service Engine and pack it into an SU and SA, the project name is hello-world-SE-SU-SA and the single pieces are named analogous. For a custom project, the IDs and names shall be altered such that they describe the purpose or function of the given piece of the SA.

First, we create a directory hello-world-SE-SU-SA and open a command line in this folder. Now we execute the following command (it has to be one line but was split to be First, we create a directory hello-world-SE-SU-SA and open a command line in this folder. Now we execute the following command (it has to be one line but was split to be readable):

Panel

mvn archetype:create -DarchetypeGroupId=org.apache.servicemix.tooling -DarchetypeArtifactId=servicemix-service-engine
-DarchetypeVersion=3.0-incubating -DgroupId=org.apache.servicemix.samples.helloWorldSE -DartifactId=hello-world-SE

...

Panel

Wiki Markup
\[INFO\] Scanning for projects...
\[INFO\] Searching repository for plugin with prefix: 'archetype'.
\[INFO\] \---------------------------------------------------------------------------\-
\[INFO\] Building Maven Default Project
\[INFO\]    task-segment: \[archetype:create\] (aggregator-style)
\[INFO\] \---------------------------------------------------------------------------\-
...
\[INFO\] <span style="color: #ff00ff">Defaulting package to group ID: org.apache.servicemix.samples.helloWorldSE</span>
...
\[INFO\] \**************\**\**\**\* End of debug info from resources from generated POM \**\**\******************\*
\[INFO\] Archetype created in<span style="color: #009900">Archetype created in dir: C:\0hellohello-world-SE-SU-SA\\hello-world-SESE</span>
\[INFO\] \-----------------------------------------------------------------------\-
\[INFO\] BUILD SUCCESSFUL
\[INFO\] \-----------------------------------------------------------------------\-

...

No Format
<pluginManagement>
	     <plugins>
			<plugin>
				          <plugin>
               <groupId>org.apache.maven.plugins</groupId>
				  <artifactId>maven-surefire-plugin</artifactId>
				  <configuration>
						               <artifactId>maven-surefire-plugin</artifactId>
               <configuration>
                    <skip>false</skip><!-- this overrides ServiceMix' root POM and forces to execute the tests -->
				  </configuration>
			               </configuration>
          </plugin>
	     </plugins>
</pluginManagement>

...

No Format
[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[INFO] Building A custom project
[INFO]    task-segment: [test]
[INFO] ----------------------------------------------------------------------------
...
[INFO] [compiler:compile]
...
[INFO] [surefire:test]
[INFO] Setting reports dir: c:\java\tmp\servicemix-helloWorldSE\target/surefire-reports
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
[surefire] Running org.apache.servicemix.samples.helloWorldSE.MySpringComponentTest
...
[surefire] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 1,422 sec
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
...

Adding functionality to the stub of the SE

Note
titleTODO

The default implementation of the component accepts InOut MEPs and return the input content as the out message.

Using an IDE to add meat to the component. You can either use IDEA or Eclipse, I tried it with Eclipse so I guess I am going to stick it for now. <TODO>

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

Creating the SU and SA and incorporating them into the main POM

The archetypes for SUs and SAs do not contain much code, but rather help with tasks related to Maven. We will only need to adapt the POMs to our project - just little work, but requiring some guidiance.

Creating the SU and SA 

In the directory hello-world-SE-

...

SU-SA we execute the following commands (they have to be one line but were split to be readable) for the SU

No Format

mvn archetype:create -DarchetypeGroupId=org.apache.servicemix.tooling -DarchetypeArtifactId=servicemix-service-unit 
-DarchetypeVersion=3.0-incubating -DgroupId=org.apache.servicemix.samples.helloWorldSE -DartifactId=hello-world-SU 

and the SU

No Format

mvn archetype:create -DarchetypeGroupId=org.apache.servicemix.tooling -DarchetypeArtifactId=servicemix-service-assembly
-DarchetypeVersion=3.0-incubating -DgroupId=org.apache.servicemix.samples.helloWorldSE -DartifactId=hello-world-SA  

Incorporating the SU and SA into the main POM

Now that we have created the SU and SA structure, we incorporate them into the main pom.xml. We create a file called pom.xml in the hello-world-SE-SU-SA directory and instert the following content:

No Format

<project>
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.apache.servicemix.samples</groupId>
	<artifactId>helloWorldSE</artifactId>
	<version>1.0-SNAPSHOT</version>
	<packaging>pom</packaging>
	<modules>
		<module>hello-world-SA</module>
		<module>hello-world-SU</module>
	</modules>
	<dependencies>
		<dependency>
			<groupId>org.apache.servicemix.samples.helloWorldSE</groupId>
			<artifactId>hello-world-SU</artifactId>
			<version>1.0-SNAPSHOT</version>
		</dependency>
	</dependencies>
</project>

The <modules> entity defines which child projects belong to the main project. The <dependencies> entity causes Maven to include the SU into the SA.

Note: The content of <version> describes not the version of ServiceMix but the project we create, thus we may choose any desired version (e.g. 3.0-final). Then you have to change it below as well.

Now, we should be able to launch Maven and have the SA generated in the hello-world-SE-SU-SA/hello-world-SA/target/ directory by running the following command from the hello-world-SE-SU-SA directory:mvn install
Of course, it won't work if you deploy it and we now need to fill the holes.

Then, deploy the SA and needed components to a started ServiceMix container:

cd hello-world-SE-SU-SA/hello-world-SA/
mvn jbi:projectDeploy

Then you can send an request to ...

Configuring the Service Assembly 

Adding functionality to the stub of the SE

The default implementation of the component accepts InOut MEPs and return the input content as the out message.

Using an IDE to add meat to the component. You can either use IDEA or Eclipse, I tried it with Eclipse so I guess I am going to stick it for now. <TODO>

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

Note
titleBe Careful

The body of the note here..

Packing into the SU

The archetypes for SUs and SAs do not contain much code, but rather help with tasks related to Maven. You will only need to adapt the generated POMs to your project - just little work, but requiring some guidiance. Here we go:

...

manually editing http://goopen.org/confluence/display/SM/Working+with+Service+Units

Packing into the SA

As mentioned above\, the archetypes for SUs and SAs mainly help with tasks related to Maven.

use the SA archetype like in /confluence/display/SM/Working+with+Service+Units
manually editing http://www.servicemix.org/site/creating-a-protocol-bridge.html/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
mvn archetype:create -DarchetypeGroupId=org.apache.servicemix.tooling -DarchetypeArtifactId=servicemix-service-assembly -DarchetypeVersion=3.0-incubating-SNAPSHOT -DgroupId=org.apache.servicemix.samples.helloWorldSE -DartifactId=hello-world-SAmanually editing http://www.servicemix.org/site/workingcreating-witha-serviceprotocol-assembliesbridge.html