osdir.com


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

What is different to createProducerTemplate via AutoConfigure and EndPointInject in SpringBoot


What is different to createProducerTemplate via AutoConfigure and
EndPointInject

in SpringBoot ?  are the both way correct?

via EndpointInject I could create multiple instance of
ProducerTemplate, but via Autoconfig I could only create one
ProducerTemplate instace



 ############################ via
EndpointInject#######################@Component
public class InvoiceProcessor {

     @EndpointInject(uri="netty-http:http://invoicing.com/received";)
    private ProducerTemplate producer;
  public void processNextInvoice() {
    Invoice invoice = consumerTemplate.receiveBody("jms:invoices",
Invoice.class);
    producer.sendBody(invoice.id());
  }
}




############## via autoconfig ############################

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