On 2010-3-11, at 上午5:21, statsquad wrote:
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.
Hi,
Yeah, you can create new Message Exchange for each script if you
really want. So the workflow looks like
1. triger::send pull data request in Message Exchange 1
2. your bean::receive Message Exchange1 and send ack reply (to finish
lifecycle of Message Exchange1, this is important )
3. your bean::get script resultset from db
4. create new MessageExchange 2 ... n for each script, and send to
your receiver which is built to read one script at a time
5. your receiver which is built to read one script at a time receive
MessageExchange 2 ... n and send ack reply
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&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?)
You mean the database generally updated by other applications but not
yourself, so you just want something like a database change event
listener so that you can get notification when database changed, IMHO
this is a more database specific question, and I'm not sure is it
possible or how to do it.
Freeman
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.
--
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com