Wang Yan
2018-11-28 20:50:01 UTC
If I use the auto configured ProducerTemplate, how could I get multiple
different ProducerTemplate instances?
for example I need use producer template send different exchanges to
different endpoints
in this case, Do i need different producer template instances? if yes how ?
Any suggestions ?
Auto-Configured Consumer and Producer Templates
Camel auto-configuration provides pre-configured *ConsumerTemplate* and
*ProducerTemplate* instances. You can simply inject them into your
Spring-managed beans:
@Component
public class InvoiceProcessor {
@Autowired
private ProducerTemplate producerTemplate;
@Autowired
private ConsumerTemplate consumerTemplate;
public void processNextInvoice() {
Invoice invoice = consumerTemplate.receiveBody("jms:invoices",
Invoice.class);
...
producerTemplate.sendBody("netty-http:http://invoicing.com/received/"
+ invoice.id());
}
}
different ProducerTemplate instances?
for example I need use producer template send different exchanges to
different endpoints
in this case, Do i need different producer template instances? if yes how ?
Any suggestions ?
Auto-Configured Consumer and Producer Templates
Camel auto-configuration provides pre-configured *ConsumerTemplate* and
*ProducerTemplate* instances. You can simply inject them into your
Spring-managed beans:
@Component
public class InvoiceProcessor {
@Autowired
private ProducerTemplate producerTemplate;
@Autowired
private ConsumerTemplate consumerTemplate;
public void processNextInvoice() {
Invoice invoice = consumerTemplate.receiveBody("jms:invoices",
Invoice.class);
...
producerTemplate.sendBody("netty-http:http://invoicing.com/received/"
+ invoice.id());
}
}