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