Versions Compared

Key

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

...

Code Block
public void process(MessageExchange exchange) throws Exception {
        // The component acts as a provider, this means that another component has requested our service
        // As this exchange is active, this is either an in or a fault (out are send by this component)
        if (exchange.getRole() == MessageExchange.Role.PROVIDER) {
            // Check here if the mep is supported by this component
            if (exchange instanceof InOut == false) {
               throw new UnsupportedOperationException("Unsupported MEP: " + exchange.getPattern());
            }
            // InNOTE: message
Added check for DONE/ERROR status -- Jeff Peterson
     if (exchange.getMessage("in") != null) {
   // TODO: FIX in archetype
         NormalizedMessage in = exchange.getMessage("in");
    // Exchange is finished
             // TODO ... handle the in message
if (exchange.getStatus() == ExchangeStatus.DONE) {
                return;
   // If the MEP is an InOnly, RobustInOnly, you have// toExchange sethas thebeen exchangeaborted towith DONEan statusexception
            } else if  // else, you have to create an Out message and populate it
(exchange.getStatus() == ExchangeStatus.ERROR) {
                return;
            // ForExchange now, just echo backis active
            } else {
  NormalizedMessage out = exchange.createMessage();
           // In    out.setContent(in.getContent());
message
                if (exchange.setMessagegetMessage(out, "outin");
 !=               channel.send(exchange);null) {
            // Fault message
      NormalizedMessage in     } else if (= exchange.getFaultgetMessage("in");
  != null) {
                // TODO ... handle the in faultmessage
                exchange.setStatus(ExchangeStatus.DONE);
    // If the MEP is an InOnly, RobustInOnly, you have to set the channel.send(exchange);
 to DONE status
         // This is not compliant with the default MEPs
   // else, you have to create an Out message }and elsepopulate {it
                 throw new IllegalStateException("Provider exchange is ACTIVE, but no in or fault is provided"); // For now, just echo back
            }
        //NormalizedMessage Theout component acts as a consumer, this means this exchange is received because
= exchange.createMessage();
                 // we sent it to another component.  As it is active, this is either an out or a fault
 out.setContent(in.getContent());
                     // If this component does not create / send exchanges, you may just throw an UnsupportedOperationException
exchange.setMessage(out, "out");
                    channel.send(exchange);
   } else if (exchange.getRole() == MessageExchange.Role.CONSUMER) {
       // Fault message
   // Exchange is finished
          } else if (exchange.getStatusgetFault() !== ExchangeStatus.DONEnull) {
                return;
    // TODO ... handle the   fault
 // Exchange has been aborted with an exception
            } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
exchange.setStatus(ExchangeStatus.DONE);
                    returnchannel.send(exchange);
            // Exchange is active
 // This is not compliant with the default MEPs
   } else {
           } else {
   // Out message
               throw if (exchange.getMessagenew IllegalStateException("out") != null) {
       Provider exchange is ACTIVE, but no in or fault is provided");
             // TODO ... handle}
 the response
          }
        //  exchange.setStatus(ExchangeStatus.DONE);
           The component acts as a consumer, this means this exchange is received because
         channel.send(exchange);
        // we sent it to another component.  As it is active, this is either an out or a fault
        // Fault message
        If this component does not create / send exchanges, you may just throw an UnsupportedOperationException
        } else if (exchange.getFaultgetRole() !== nullMessageExchange.Role.CONSUMER) {
            // Exchange is finished
     // TODO ... handle the fault
  if (exchange.getStatus() == ExchangeStatus.DONE) {
              exchange.setStatus(ExchangeStatus.DONE)  return;
            // Exchange has been aborted with   channel.send(exchange);an exception
            } else if  // This is not compliant with the default MEPs
   (exchange.getStatus() == ExchangeStatus.ERROR) {
                return;
            // }Exchange elseis {active
            } else {
      throw new IllegalStateException("Consumer exchange is ACTIVE, but no out or fault// is provided");Out message
                }
    if (exchange.getMessage("out") != null) {
        }
        // Unknown role
  // TODO ... handle the response
 } else {
            throw new IllegalStateException("Unkown role: " + exchange.getRolesetStatus()ExchangeStatus.DONE);
            }
    }

The implementation of the method above was provided by the servicemix-service-engine Maven archetype. This method is very generic and contains a conditional block for handling either a consumer or a provider role. But this method will still require us to make the decision of which style of Message Exchange Pattern (MEP) to handle. In the case of the Hello World SE, we know that it is a provider so it will need to send a return message. Therefore it will need to handle an In-Out MEP. So instead of having MyEndpoint extend the very basic Endpoint class and implement its own process() method, we're going to extend a different class that is specifically for provider endpoints named
ProviderEndpoint.

Image Removed

Notice the diagram above showing the class hierarchy of Endpoint. The ProviderEndpoint supplies some additional conveniences for provider components beyond what the Endpoint class provides and will make the job of implementing MyEndpoint as a provider much easier. So let's make some changes to the MyEndpoint class. First remove the process() method shown above. Second, change the definition of the MyEndpoint class from this:

Code Block

public class MyEndpoint extends Endpoint implements ExchangeProcessor

to this:

Code Block

public class MyEndpoint extends ProviderEndpoint implements ExchangeProcessor

By the way, making this change will require the import of the full class (org.apache.servicemix.common.endpoints.ProviderEndpoint). This class can be found in the servicemix-common project.

Third, because the ProviderEndpoint.process() method already handles an In-Out MEP (and other MEPs), MyEndpoint will simply need to override the ProviderEndpoint.processInOut() method. Below is the content for implementing this method. Copy/paste this method:

Code Block

protected void processInOut(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws Exception {
	SourceTransformer sourceTransformer = new SourceTransformer();
	String inMessage = sourceTransformer.toString(in.getContent()); 
	out.setContent(new StringSource("<hello>Hello World! Message [" + inMessage + "] contains [" + inMessage.getBytes().length + "] bytes</hello>."));
}

Adding this method will require the import of the following classes:

  • org.apache.servicemix.jbi.jaxp.SourceTransformer
  • org.apache.servicemix.jbi.jaxp.StringSource

These classes can be found in the servicemix-core project.

This method is the custom functionality for the Hello World SE. We're not doing anything complex here at all in order to keep this tutorial very simple. Apache Ode was mentioned earlier as an example of an engine that can be deployed as a JBI SE, this class is where Ode would be referenced and called. If you're interested to see how Ode is called, see the BPEEndpoint class for the details. Now it's time to test the Hello World SE.

Testing the Hello World Component

Thanks to the archetype, testing the component is very easy because it already created a test. The only change we'll make is to the string being sent by the client code. In the src/test/java directory is the org.apache.servicemix.samples.helloworld.se.MySpringComponentTest test. Simply open this test and change line #36 from this:

Code Block

me.getInMessage().setContent(new StringSource("<hello>world</hello>"));

to something more meaningful, like this:

Code Block

me.getInMessage().setContent(new StringSource("<hello>Ski Colorado!</hello>"));

To execute the test, simply run the Maven install goal from within the hello-world-se directory like so:

Code Block

$ mvn install 

Below is the output that will print to the console:

...

    channel.send(exchange);
                // Fault message
                } else if (exchange.getFault() != null) {
                    // TODO ... handle the fault
                    exchange.setStatus(ExchangeStatus.DONE);
                    channel.send(exchange);
                // This is not compliant with the default MEPs
                } else {
                    throw new IllegalStateException("Consumer exchange is ACTIVE, but no out or fault is provided");
                }
            }
        // Unknown role
        } else {
            throw new IllegalStateException("Unkown role: " + exchange.getRole());
        }
    }

The implementation of the method above was provided by the servicemix-service-engine Maven archetype. This method is very generic and contains a conditional block for handling either a consumer or a provider role. But this method will still require us to make the decision of which style of Message Exchange Pattern (MEP) to handle. In the case of the Hello World SE, we know that it is a provider so it will need to send a return message. Therefore it will need to handle an In-Out MEP. So instead of having MyEndpoint extend the very basic Endpoint class and implement its own process() method, we're going to extend a different class that is specifically for provider endpoints named
ProviderEndpoint.

Image Added

Notice the diagram above showing the class hierarchy of Endpoint. The ProviderEndpoint supplies some additional conveniences for provider components beyond what the Endpoint class provides and will make the job of implementing MyEndpoint as a provider much easier. So let's make some changes to the MyEndpoint class. First remove the process() method shown above. Second, change the definition of the MyEndpoint class from this:

Code Block

public class MyEndpoint extends Endpoint implements ExchangeProcessor

to this:

Code Block

public class MyEndpoint extends ProviderEndpoint implements ExchangeProcessor

By the way, making this change will require the import of the full class (org.apache.servicemix.common.endpoints.ProviderEndpoint). This class can be found in the servicemix-common project.

Third, because the ProviderEndpoint.process() method already handles an In-Out MEP (and other MEPs), MyEndpoint will simply need to override the ProviderEndpoint.processInOut() method. Below is the content for implementing this method. Copy/paste this method:

Code Block

protected void processInOut(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws Exception {
	SourceTransformer sourceTransformer = new SourceTransformer();
	String inMessage = sourceTransformer.toString(in.getContent()); 
	out.setContent(new StringSource("<hello>Hello World! Message [" + inMessage + "] contains [" + inMessage.getBytes().length + "] bytes</hello>."));
}

Adding this method will require the import of the following classes:

  • org.apache.servicemix.jbi.jaxp.SourceTransformer
  • org.apache.servicemix.jbi.jaxp.StringSource

These classes can be found in the servicemix-core project.

This method is the custom functionality for the Hello World SE. We're not doing anything complex here at all in order to keep this tutorial very simple. Apache Ode was mentioned earlier as an example of an engine that can be deployed as a JBI SE, this class is where Ode would be referenced and called. If you're interested to see how Ode is called, see the BPEEndpoint class for the details. Now it's time to test the Hello World SE.

Testing the Hello World Component

Thanks to the archetype, testing the component is very easy because it already created a test. The only change we'll make is to the string being sent by the client code. In the src/test/java directory is the org.apache.servicemix.samples.helloworld.se.MySpringComponentTest test. Simply open this test and change line #36 from this:

Code Block

me.getInMessage().setContent(new StringSource("<hello>world</hello>"));

to something more meaningful, like this:

Code Block

me.getInMessage().setContent(new StringSource("<hello>Ski Colorado!</hello>"));

To execute the test, simply run the Maven install goal from within the hello-world-se directory like so:

Code Block

$ mvn install 

Below is the output that will print to the console:

No Format

[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[INFO] Building A custom project
[INFO]    task-segment: [install]
[INFO] ----------------------------------------------------------------------------
[INFO] [xbean:mapping {execution: default}]
Checking: org.apache.servicemix.samples.helloworld.se.MyComponent
Checking: /1.0
[INFO] Generating Spring 2.0 handler mapping: /Users/bsnyder/src/hello-world-smx/hello-world-se/target/xbean/META-INF/spring.handlers 
for namespace: http://org.apache.servicemix.samples.helloworld.se/1.0
[INFO] Generating Spring 2.0 schema mapping: /Users/bsnyder/src/hello-world-smx/hello-world-se/target/xbean/META-INF/spring.schemas 
for namespace: http://org.apache.servicemix.samples.helloworld.se/1.0
[INFO] Generating HTML documentation file: /Users/bsnyder/src/hello-world-smx/hello-world-se/target/xbean/hello-world-se.xsd.html 
for namespace: http://org.apache.servicemix.samples.helloworld.se/1.0
[INFO] Generating XSD file: /Users/bsnyder/src/hello-world-smx/hello-world-se/target/xbean/hello-world-se.xsd 
for namespace: http://org.apache.servicemix.samples.helloworld.se/1.0MyEndpoint
[INFO] Generating WIKIMETA-INF documentationproperties file: /Users/bsnyder/src/hello-world-smx/hello-world-se/target/xbean/hello-world-se.xsd.wiki 
for namespace: http://orgMETA-INF/services/org/apache/xbean/spring/http/
org.apache.servicemix.samples.helloworld.se/1.0 
Warning,for could not load class: namespace: http://org.apache.servicemix.samples.helloworld.se/1.MyEndpoint0
[INFO] Generating Spring 2...done.
Downloading0 handler mapping: /Users/bsnyder/src/hello-world-smx/hello-world-se/target/xbean/META-INF/spring.handlers 
for namespace: http://repoorg.apache.mergere.com/maven2/xml-security/xmlsec/1.3.0/xmlsec-1.3.0.pom
[WARNING] Unable to get resource from repository central (http://repo1.maven.org/maven2)
Downloadingservicemix.samples.helloworld.se/1.0
[INFO] Generating Spring 2.0 schema mapping: /Users/bsnyder/src/hello-world-smx/hello-world-se/target/xbean/META-INF/spring.schemas 
for namespace: http://repoorg.apache.mergere.com/maven2/wss4j/wss4j/1.5.0/wss4j-1.5.0.pom
[WARNING] Unable to get resource from repository central (http://repo1.maven.org/maven2)
[INFO] [jbi:generate-jbi-component-descriptor]
[INFO] Generating jbi.xml
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] Surefire report directory: /Users/bsnyder/src/hello-world-smx/hello-world-se/target/surefire-reports

-------------------------------------------------------
 T E S T S
------------servicemix.samples.helloworld.se/1.0
[INFO] Generating HTML documentation file: /Users/bsnyder/src/hello-world-smx/hello-world-se/target/xbean/hello-world-se.xsd.html 
for namespace: http://org.apache.servicemix.samples.helloworld.se/1.0
[INFO] Generating XSD file: /Users/bsnyder/src/hello-world-smx/hello-world-se/target/xbean/hello-world-se.xsd 
for namespace: http://org.apache.servicemix.samples.helloworld.se/1.0
[INFO] Generating WIKI documentation file: /Users/bsnyder/src/hello-world-smx/hello-world-se/target/xbean/hello-world-se.xsd.wiki 
for namespace: http://org.apache.servicemix.samples.helloworld.se/1.0
Warning, could not load class: org.apache.servicemix.samples.helloworld.se.MyEndpoint
[INFO] ...done.
Downloading: http://repo.mergere.com/maven2/xml-security/xmlsec/1.3.0/xmlsec-1.3.0.pom
[WARNING] Unable to get resource from repository central (http://repo1.maven.org/maven2)
Downloading: http://repo.mergere.com/maven2/wss4j/wss4j/1.5.0/wss4j-1.5.0.pom
[WARNING] Unable to get resource from repository central (http://repo1.maven.org/maven2)
[INFO] [jbi:generate-jbi-component-descriptor]
[INFO] Generating jbi.xml
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] Surefire report directory: /Users/bsnyder/src/hello-world-smx/hello-world-se/target/surefire-reports

-------------------------------------------
Running org.apache.servicemix.samples.helloworld.se.MySpringComponentTest
<hello>Hello World! Message [<hello>Ski Colorado!</hello>] contains [28] bytes</hello>.
Tests run: 1------------
 T E S T S
-------------------------------------------------------
Running org.apache.servicemix.samples.helloworld.se.MySpringComponentTest
<hello>Hello World! Message [<hello>Ski Colorado!</hello>] contains [28] bytes</hello>.
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.487 sec

Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] [jar:jar]
[INFO] Building jar: /Users/bsnyder/src/hello-world-smx/hello-world-se/target/hello-world-se-1.0-SNAPSHOT.jar
[INFO] [jbi:jbi-component]
[INFO] Generating installer /Users/bsnyder/src/hello-world-smx/hello-world-se/target/hello-world-se-1.0-SNAPSHOT-installer.zip
[INFO] Building jar: /Users/bsnyder/src/hello-world-smx/hello-world-se/target/hello-world-se-1.0-SNAPSHOT-installer.zip
[INFO] [install:install]
[INFO] Installing /Users/bsnyder/src/hello-world-smx/hello-world-se/target/hello-world-se-1.0-SNAPSHOT.jar to 
/Users/bsnyder/.m2/repository/org/apache/servicemix/samples/helloworld/se/hello-world-se/1.0-SNAPSHOT/hello-world-se-1.0-SNAPSHOT.jar
[INFO] Installing /Users/bsnyder/src/hello-world-smx/hello-world-se/target/xbean/hello-world-se.xsd to 
/Users/bsnyder/.m2/repository/org/apache/servicemix/samples/helloworld/se/hello-world-se/1.0-SNAPSHOT/hello-world-se-1.0-SNAPSHOT.xsd
[INFO] Installing /Users/bsnyder/src/hello-world-smx/hello-world-se/target/xbean/hello-world-se.xsd.html to 
/Users/bsnyder/.m2/repository/org/apache/servicemix/samples/helloworld/se/hello-world-se/1.0-SNAPSHOT/hello-world-se-1.0-SNAPSHOT-schema.html
[INFO] Installing /Users/bsnyder/src/hello-world-smx/hello-world-se/target/hello-world-se-1.0-SNAPSHOT-installer.zip to 
/Users/bsnyder/.m2/repository/org/apache/servicemix/samples/helloworld/se/hello-world-se/1.0-SNAPSHOT/hello-world-se-1.0-SNAPSHOT-installer.zip
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16 seconds
[INFO] Finished at: Mon Jan 15 13:19:51 MST 2007
[INFO] Final Memory: 13M/24M
[INFO] ------------------------------------------------------------------------

...

In order to actually make use of the component, you will need to deploy a configuration for the component. Once JBI components are deployed to the JBI container, they're just hanging out there waiting for a configuration to be deployed to them. This is why JBI is often referred to as a container of containers. The JBI container accepts deployment of JBI components and JBI components accept deployment of service units (SUs) that configure them. This is very similar to the way RAR files work in JavaEE-land. RAR files are generic components that are deployed to the JavaEE container that accept the deployment of a configuration file to tell it how to run. This is exactly how JBI components work. To achieve this, you need to create a JBI SU that depends on the JBI component in it's pom.xml file and to deploy the SU to the JBI container as well.

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:

deployed to the JavaEE container that accept the deployment of a configuration file to tell it how to run. This is exactly how JBI components work. To achieve this, you need to create a JBI SU that depends on the JBI component in it's pom.xml file and to deploy the SU to the JBI container as well.

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

$ 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-repositoryImage Added

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

Panel

<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.

Configure hello-world-su

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

Code Block

<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>
Info

TODO: explain

Create a Service Unit for HTTP Binding Component

This service unit will configure the servicemix-http binding component so we can issue some soap-over-http requests for testing purposes.

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-bc-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-bc-su

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

Code Block

<?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:bae="http://baesystems.com">

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

    <http:endpoint service="bae: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 tie together all of the service units

Code Block

$ mvn archetype:create \
Panel
$ mvn archetype:create \
-DarchetypeGroupId=org.apache.servicemix.tooling \


-DarchetypeArtifactId=servicemix-service-
unit
assembly \


-DarchetypeVersion=3.1-incubating \


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


-DartifactId=hello-world-
su
sa \


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

There should now be a hello-world-sa directory under This create a directory named hello-world-susmx. Now edit the pom.xml file to add the following dependency on the Hello World SE:

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

Code Block

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


  <artifactId>hello-world-
se<
bc-su</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.


This This is a work in progress

Incorporating the Projects Into a Top Level POM

...

Code Block
<?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-bc-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 

$ ls 
hello-world-bc-su  hello-world-sa  hello-world-se  hello-world-su  pom.xml

All projects can now be built using the following command on the command-line from the top level hello-world-smx directory:

...

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

...

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

Now that the SA is built, we're ready to deploy it 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-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.

Step 10: 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 Added
  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.

...