Hi All,

How can I send multiple messages from a servicemix-bean ? What is the
recommended way of doing this? Can I send multiple messages back in response
to one single message? Please advise

I am using Servicemix 4.1.0-SNAPSHOT and created an OSGI bundle for the
service

Context

I am trying to read a bunch of records from a database (using spring-jdbc),
parse them seperately into normalized messages and send them to the nmr
(camel-nmr). I was successful in using spring-jdbc and retrieve the records
but I get this exception when I try to send multiple records (as multiple
messages) as part of a single message exchange. Is this a correct way of
doing it?

Exception
javax.jbi.messaging.MessagingException: Out message already setReceived
exchange: org.apache.servicemix.jbi.runtime.impl.InOutImpl
@22ed8e

        at
org.apache.servicemix.jbi.runtime.impl.MessageExchangeImpl.setOutMessage(MessageExchangeImpl.java:188)printing
message

Code

code 

public class SendStockNMR implements MessageExchangeListener {
public void onMessageExchange(MessageExchange exchange) throws
MessagingException {
ArrayList list = (ArrayList)stockDao.getStockElements();
Iterator listIterator = list.iterator();
while(listIterator.hasNext()){
        stockelement script = (stockelement)listIterator.next();
        NormalizedMessage message =exchange.getMessage("in");
        message.setContent(new StringSource(script.toString()));
        exchange.setMessage(message, "out");
        channel.send(exchange);
        }
}
}       

Thanks,
Deepak Bysani


-- 
View this message in context: 
http://old.nabble.com/Error-when-sending-multiple-messages-from-a-servicemix-bean-tp27849967p27849967.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to