Thanks for the quick response Freeman but What if the receiver is built to
read one script at a time? Can we initiate a new message exchange from
within the servicemix-bean? This way for each script, I can initiate a new
message exchange.

Also, Is this the only way you could poll a database, look for updates at
regular intervals and send messages to the bus?

I am currently using something like this:


        <camel-osgi:camelContext xmlns="http://camel.apache.org/schema/spring";>
                <route>
                        <from 
uri="timer://myTimera?fixedRate=true&amp;period=500" />
                        <to 
uri="jbi:endpoint:urn:test:example:myService:listener?mep=in-out" />
                </route>
        </camel-osgi:camelContext>


A timer component which triggers off a service-mix bean to look for updates
to DB. This is polling. Is there a more efficient way to do this in
servicemix? (Something like data push instead of pull?)


Thanks in advance,
Deepak Bysani,




Freeman Fang wrote:
> 
> 
> On 2010-3-10, at 下午9:57, statsquad wrote:
> 
>>
>>
>> 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);
>>      }
>> }
>> }    
> 
> Hi,
> 
> No, I don't think you can do like that, you should only set one out  
> message per exchange.
> If you just want out message to carry more infos, you can do some kind  
> of marshaling work
> for result set,  for example, the out message payload can looks like
> 
> <resultSet>
>    <script>..</script>
>    <script>..</script>
>    <script>..</script>
>    <script>..</script>
> </resultSet>
> 
> And you need do unmarshall when the other side receive out message.
> 
> Freeman
>>
>> 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.
>>
> 
> 
> -- 
> Freeman Fang
> ------------------------
> Open Source SOA: http://fusesource.com
> 
> 
> 

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

Reply via email to