git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how could I get multiple different ProducerTemplate instances with Auto-Configured Producer Templates


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());
  }
}