camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nhan Nguyen <ntnha...@gmail.com>
Subject The producer sent only one message but the comsumer received multiple messages with same content.
Date Sun, 04 Aug 2013 08:04:48 GMT
Hi all,

I am using a Topic to send and receive the message:

from("jms:topic:topic1").process(new Processor() {
					
	@Override
	public void process(Exchange exchange) throws Exception {
		System.out.println(exchange.getIn().getBody());
	}
});


The code to send the message:

endPoint = getCamelContext().getEndpoint("jms:topic:topic1",
JmsEndpoint.class);
producer = getCamelContext().createProducerTemplate();
int i = 0;
while(true){
	Exchange exchange = endpoint.createExchange();
        exchange.setPattern(ExchangePattern.InOnly);
	exchange .setBody(i++);
	m_producer.send(endPoint, exchange);
	Thread.sleep(1000);
}

I sent a message, wait for 1second, then send another with the content is
i++. And the output I saw:

0
1
1
2
2
2
3
3
3
3

Why did I receive so many same messages? I expected the result must be:
0
1
2
3


Can someone help me on this? Thanks!



--
View this message in context: http://camel.465427.n5.nabble.com/The-producer-sent-only-one-message-but-the-comsumer-received-multiple-messages-with-same-content-tp5736733.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message