如何使用以下代码中的“jmsQueueConsumer:queue:consumer.queue”消息:
CamelContext context1 = new DefaultCamelContext();
ConnectionFactory connectionFactory1 = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
ConnectionFactory connectionFactory2 = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
context1.addComponent("jmsQueueProducer", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory1));
context1.addComponent("jmsQueueConsumer", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory2));
context1.addRoutes(new RouteBuilder() {
public void configure() {
from("jmsQueueProducer:queue:producer.queue").to("jmsQueueConsumer:queue:consumer.queue");
}
});
ProducerTemplate template = context1.createProducerTemplate();
context1.start();
for (int i = 0; i < 10; i++) {
template.sendBody("jmsQueueProducer:queue:producer.queue", "Test Message: " + i);
}