I have some questions on this.
Why it is checking exchange status is active before doing anything?. 

Antony


Jean-Baptiste Onofré wrote:
> 
> 
> public class ListenerBean implements MessageExchangeListener {
> 
>      @Resource
>      private DeliveryChannel channel;
> 
>      public void onMessageExchange(MessageExchange exchange) throws 
> MessagingException {
>          if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
>                          NormalizedMessage message = 
> exchange.getMessage("in");
>                  Source content = message.getContent();
>              //process content according to your logic
>              //e.g. to access the message body as a String use
>              String body = (new SourceTransformer()).toString(content);
>              body = MyPOJO.transform(body);
>              message.setContent(new StringSource(body));
>              exchange.setMessage(message, "out");
>              channel.send(exchange);
>          }
>      }
> 
> }
> 
> This POJO is the listener one: it receives a message, extracts the 
> content and send out (if the MEP InOut is used).
> 
> You can deploy it with the following xbean.xml:
> <bean:endpoint service="MyService" endpoint="listener" bean="#myBean"/>
> <bean id="myBean" class="com.my.package.Bean"/>
> 
> For the poller, you can use servicemix-quartz component to call a bean 
> that trigger the message sending. You can define your own 
> servicemix-quartz marshaler to define the message content. After you 
> deploy it using a xbean.xml like this:
> 
> <quartz:endpoint service="MyService endpoint="provider" 
> targetService="MyService" endpoint="listener">
>    <quartz:jobDetail>
>      <quartz:jobDetail>
>        <quartz:jobDataAsMap>
>          <quartz:property key="xml"><![CDATA[
>            <hello>world</hello>
>          ]]></quartz:property>
>        </quartz:jobDataAsMap>
>      </quartz:jobDetail>
>    </quartz:jobDetail>
>    <quartz:triggers>
>      <quartz:simple repeatCount="0" repeatInterval="1000" />
>      <quartz:cron cronExpression="0 * 1 * * ?" />
>    </quartz:triggers>
>    <quartz:marshaler>
>      <bean class="org.apache.servicemix.quartz.CustomMarshaler" />
>    </quartz:marshaler>
> </quartz:endpoint>
> 
> Regards
> JB
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-Fwd%3A-Re%3A-Message-Exchange-between-two-POJO%27s--tp23561289p23590756.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to