Versions Compared

Key

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

...

The implementation of this method was provided by the servicemix-service-engine Maven archetype and is shown in the code snippet above. Because the archetype can be used to create a consumer or a provider, 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 as well. 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 InOut In-Out MEP.

Instead of having MyEndpoint extend the very basic Endpoint class, we're going to extend a different class that is specifically for provider endpoints named ProviderEndpoint. Notice the diagram above showing the class hierarchy of Endpoint. The ProviderEndpoint supplies some additional conveniences for provider components and will make the job of implementing MyEndpoint as a provider much easier. So change the definition of MyEndpoint from this:

...

Code Block
public class MyEndpoint extends ProviderEndpoint implements ExchangeProcessor

Because the ProviderEndpoint.process() method already handles an In-Out MEP, MyEndpoint will simply need to override the ProviderEndpoint.processInOut() method. Below is the content for this method:

Code Block

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

Creating the Maven Subprojects For the Service Unit and Service Assembly

...