Creating the service assembly

With the service units prepared, we are now ready to use a Maven archetype to create a service assembly

Creating the service assembly (SA)

Just as we started our service unit with a Maven archetype, we are also going to use a Maven archetype (servicemix-service-assembly) to create the SA project. Run this command from the directory that holds your parent pom.xml:

mvn archetype:create \
  -DarchetypeArtifactId=servicemix-service-assembly \
  -DarchetypeGroupId=org.apache.servicemix.tooling \
  -DgroupId=org.apache.servicemix.examples \
  -DartifactId=http-upload-sa

A new service assembly project is generated in the http-upload-sa directory.

Editing pom.xml

Changing the project name

Again, to clean up the build output, we change the project's name

<?xml version="1.0" encoding="UTF-8"?>
<project>
  ...
  <name>Http Uploader :: Uploader SA</name>
  ...
</project>

Adding the SUs to the SA

We want to add the service units we created before to the service assembly. The Maven tooling will do this automatically if we add the correct dependency to our SA's pom.xml. We just use the groupId, artifactId and version we find in our service unit's pom.xml here:

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>org.apache.servicemix.examples</groupId>
      <artifactId>http-consumer-su</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
      <groupId>org.apache.servicemix.examples</groupId>
      <artifactId>http-handler-su</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>
  </dependencies>
  ...
</project>

Running Maven to build everything

Now, run mvn clean install from the projects root directory to build the whole project.
The output should say that the build of all components succeeded.

...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9 seconds
[INFO] Finished at: Mon Jul 30 16:23:42 CEST 2007
[INFO] Final Memory: 23M/56M
[INFO] ------------------------------------------------------------------------

Now, we are ready to deploy our service assembly. For doing this we just copy the created service assembly jar file (http-upload-sa/target/http-upload-sa-1.0-SNAPSHOT.jar) into the hotdeploy folder of your ServiceMix installation. Watch the service mix console window for success (or maybe errors).

Further reading

Things to remember

  • You can use the servicemix-service-assembly archetype to quickly create a Maven SA project.
  • Add SU to your SA by adding dependencies to your pom.xml

Proceed to the next step