Try to use sendSync() on the delivery channel in place of send().

Check the MEP of your message too.

Regards
JB

On 09/16/2010 02:03 PM, alexcpn wrote:

Hi,
  My use case is like this; From a file poller I get the message to my
servicemix-bean; I do something with the message; After a count is reached I
want to send a consolidated message to a file sender. I tried something like
this and evidently the endpoint is not getting injected;

----------------------------------
xbean is like this

  <file:poller service="test:inmc_filepoller"
                endpoint="endpoint"
                targetService="test:inmc_aggregator_pipeline"
                file="d:\temp\_del\pollertest">

   </file:poller>

-----------------------------------
public class MyBean implements MessageExchangeListener {

     @Resource
     private DeliveryChannel channel;


@ExchangeTarget(uri="endpoint:http://servicemix.apache.org/test/file_sender_getbulk/endpoint";)
     private Destination target;


     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
                        try {
                                String body = (new 
SourceTransformer()).toString(content);
                        } catch (TransformerException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }
                        
                        MessageExchange exchange2 
=target.createInOnlyExchange();
                        
                        message.setContent(content);
                        exchange2.setMessage(message, "in");
                        channel.send(exchange2);
                        
         }
     }

}

-----------------

ERROR - BeanComponent                  - Error processing exchange InOnly[
   id: ID:169.254.241.150-12b1a502016-14:150
   status: Active
   role: provider
   service: {http://servicemix.apache.org/test}aggregatorbean
   endpoint: bean
   in: Unable to display: java.io.IOException: Stream closed
]
java.lang.NullPointerException
         at
com.nsn.isuite.aggregator.MyBean.onMessageExchange(MyBean.java:40)
         at
org.apache.servicemix.bean.BeanEndpoint.onProviderExchange(BeanEndpoint.java:230)
         at
org.apache.servicemix.bean.BeanEndpoint.process(BeanEndpoint.java:217)
         at
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:627)
         at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:581)
         at
org.apache.servicemix.common.AsyncBaseLifeCycle.onMessageExchange(AsyncBaseLifeCycle.java:535)
         at
org.apache.servicemix.common.SyncLifeCycleWrapper.onMessageExchange(SyncLifeCycleWrapper.java:60)
         at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:632)
         at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:185)
         at
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:168)
         at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
         at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
         at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
         at java.lang.Thread.run(Thread.java:619)
WARN  - FileComponent                  - Message in file
d:\temp\_del\pollertest\test.txt could not be handled successfully: null


--
Jean-Baptiste Onofré
---------------------------------
 HomePage
http://www.nanthrax.net
---------------------------------
 Contacts
[email protected]
[email protected]
---------------------------------
 OpenSource
BuildProcess/AutoDeploy
http://buildprocess.sourceforge.net
Apache ServiceMix
http://servicemix.apache.org
-----------------------------------
PGP : 17D4F086

Reply via email to