Class DefaultProducerTemplate

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.impl.engine.DefaultProducerTemplate
All Implemented Interfaces:
AutoCloseable, org.apache.camel.ProducerTemplate, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

public class DefaultProducerTemplate extends org.apache.camel.support.service.ServiceSupport implements org.apache.camel.ProducerTemplate
Template (named like Spring's TransactionTemplate invalid input: '&' JmsTemplate et al) for working with Camel and sending Message instances in an Exchange to an Endpoint.
  • Constructor Details

    • DefaultProducerTemplate

      public DefaultProducerTemplate(org.apache.camel.CamelContext camelContext)
    • DefaultProducerTemplate

      public DefaultProducerTemplate(org.apache.camel.CamelContext camelContext, ExecutorService executor)
    • DefaultProducerTemplate

      public DefaultProducerTemplate(org.apache.camel.CamelContext camelContext, org.apache.camel.Endpoint defaultEndpoint)
  • Method Details

    • newInstance

      public static DefaultProducerTemplate newInstance(org.apache.camel.CamelContext camelContext, String defaultEndpointUri)
    • getMaximumCacheSize

      public int getMaximumCacheSize()
      Specified by:
      getMaximumCacheSize in interface org.apache.camel.ProducerTemplate
    • setMaximumCacheSize

      public void setMaximumCacheSize(int maximumCacheSize)
      Specified by:
      setMaximumCacheSize in interface org.apache.camel.ProducerTemplate
    • isThreadedAsyncMode

      public boolean isThreadedAsyncMode()
      Specified by:
      isThreadedAsyncMode in interface org.apache.camel.ProducerTemplate
    • setThreadedAsyncMode

      public void setThreadedAsyncMode(boolean useExecutor)
      Specified by:
      setThreadedAsyncMode in interface org.apache.camel.ProducerTemplate
    • getCurrentCacheSize

      public int getCurrentCacheSize()
      Specified by:
      getCurrentCacheSize in interface org.apache.camel.ProducerTemplate
    • isEventNotifierEnabled

      public boolean isEventNotifierEnabled()
      Specified by:
      isEventNotifierEnabled in interface org.apache.camel.ProducerTemplate
    • cleanUp

      public void cleanUp()
      Specified by:
      cleanUp in interface org.apache.camel.ProducerTemplate
    • setEventNotifierEnabled

      public void setEventNotifierEnabled(boolean eventNotifierEnabled)
      Specified by:
      setEventNotifierEnabled in interface org.apache.camel.ProducerTemplate
    • send

      public org.apache.camel.Exchange send(String endpointUri, org.apache.camel.Exchange exchange)
      Specified by:
      send in interface org.apache.camel.ProducerTemplate
    • send

      public org.apache.camel.Exchange send(String endpointUri, org.apache.camel.Processor processor)
      Specified by:
      send in interface org.apache.camel.ProducerTemplate
    • send

      public org.apache.camel.Exchange send(String endpointUri, org.apache.camel.ExchangePattern pattern, org.apache.camel.Processor processor)
      Specified by:
      send in interface org.apache.camel.ProducerTemplate
    • send

      public org.apache.camel.Exchange send(org.apache.camel.Endpoint endpoint, org.apache.camel.Exchange exchange)
      Specified by:
      send in interface org.apache.camel.ProducerTemplate
    • send

      public org.apache.camel.Exchange send(org.apache.camel.Endpoint endpoint, org.apache.camel.Processor processor)
      Specified by:
      send in interface org.apache.camel.ProducerTemplate
    • send

      public org.apache.camel.Exchange send(org.apache.camel.Endpoint endpoint, org.apache.camel.ExchangePattern pattern, org.apache.camel.Processor processor)
      Specified by:
      send in interface org.apache.camel.ProducerTemplate
    • send

      public org.apache.camel.Exchange send(org.apache.camel.Endpoint endpoint, org.apache.camel.ExchangePattern pattern, org.apache.camel.Processor processor, org.apache.camel.Processor resultProcessor)
      Specified by:
      send in interface org.apache.camel.ProducerTemplate
    • send

      public org.apache.camel.Exchange send(org.apache.camel.Endpoint endpoint, org.apache.camel.Exchange exchange, org.apache.camel.Processor resultProcessor)
    • sendBody

      public Object sendBody(org.apache.camel.Endpoint endpoint, org.apache.camel.ExchangePattern pattern, Object body)
      Specified by:
      sendBody in interface org.apache.camel.ProducerTemplate
    • sendBody

      public void sendBody(org.apache.camel.Endpoint endpoint, Object body) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBody in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • sendBody

      public void sendBody(String endpointUri, Object body) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBody in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • sendBody

      public Object sendBody(String endpointUri, org.apache.camel.ExchangePattern pattern, Object body) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBody in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • sendBodyAndHeader

      public void sendBodyAndHeader(String endpointUri, Object body, String header, Object headerValue) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBodyAndHeader in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • sendBodyAndHeader

      public void sendBodyAndHeader(org.apache.camel.Endpoint endpoint, Object body, String header, Object headerValue) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBodyAndHeader in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • sendBodyAndHeader

      public Object sendBodyAndHeader(org.apache.camel.Endpoint endpoint, org.apache.camel.ExchangePattern pattern, Object body, String header, Object headerValue) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBodyAndHeader in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • sendBodyAndHeader

      public Object sendBodyAndHeader(String endpoint, org.apache.camel.ExchangePattern pattern, Object body, String header, Object headerValue) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBodyAndHeader in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • sendBodyAndProperty

      public void sendBodyAndProperty(String endpointUri, Object body, String property, Object propertyValue) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBodyAndProperty in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • sendBodyAndProperty

      public void sendBodyAndProperty(org.apache.camel.Endpoint endpoint, Object body, String property, Object propertyValue) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBodyAndProperty in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • sendBodyAndProperty

      public Object sendBodyAndProperty(org.apache.camel.Endpoint endpoint, org.apache.camel.ExchangePattern pattern, Object body, String property, Object propertyValue) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBodyAndProperty in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • sendBodyAndProperty

      public Object sendBodyAndProperty(String endpoint, org.apache.camel.ExchangePattern pattern, Object body, String property, Object propertyValue) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBodyAndProperty in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • sendBodyAndHeaders

      public void sendBodyAndHeaders(String endpointUri, Object body, Map<String,Object> headers) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBodyAndHeaders in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • sendBodyAndHeaders

      public void sendBodyAndHeaders(org.apache.camel.Endpoint endpoint, Object body, Map<String,Object> headers) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBodyAndHeaders in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • sendBodyAndHeaders

      public Object sendBodyAndHeaders(String endpointUri, org.apache.camel.ExchangePattern pattern, Object body, Map<String,Object> headers) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBodyAndHeaders in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • sendBodyAndHeaders

      public Object sendBodyAndHeaders(org.apache.camel.Endpoint endpoint, org.apache.camel.ExchangePattern pattern, Object body, Map<String,Object> headers) throws org.apache.camel.CamelExecutionException
      Specified by:
      sendBodyAndHeaders in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • request

      public org.apache.camel.Exchange request(org.apache.camel.Endpoint endpoint, org.apache.camel.Processor processor)
      Specified by:
      request in interface org.apache.camel.ProducerTemplate
    • requestBody

      public Object requestBody(Object body) throws org.apache.camel.CamelExecutionException
      Specified by:
      requestBody in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • requestBody

      public Object requestBody(org.apache.camel.Endpoint endpoint, Object body) throws org.apache.camel.CamelExecutionException
      Specified by:
      requestBody in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • requestBodyAndHeader

      public Object requestBodyAndHeader(Object body, String header, Object headerValue) throws org.apache.camel.CamelExecutionException
      Specified by:
      requestBodyAndHeader in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • requestBodyAndHeader

      public Object requestBodyAndHeader(org.apache.camel.Endpoint endpoint, Object body, String header, Object headerValue) throws org.apache.camel.CamelExecutionException
      Specified by:
      requestBodyAndHeader in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • request

      public org.apache.camel.Exchange request(String endpointUri, org.apache.camel.Processor processor) throws org.apache.camel.CamelExecutionException
      Specified by:
      request in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • requestBody

      public Object requestBody(String endpointUri, Object body) throws org.apache.camel.CamelExecutionException
      Specified by:
      requestBody in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • requestBodyAndHeader

      public Object requestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue) throws org.apache.camel.CamelExecutionException
      Specified by:
      requestBodyAndHeader in interface org.apache.camel.ProducerTemplate
      Throws:
      org.apache.camel.CamelExecutionException
    • requestBodyAndHeaders

      public Object requestBodyAndHeaders(String endpointUri, Object body, Map<String,Object> headers)
      Specified by:
      requestBodyAndHeaders in interface org.apache.camel.ProducerTemplate
    • requestBodyAndHeaders

      public Object requestBodyAndHeaders(org.apache.camel.Endpoint endpoint, Object body, Map<String,Object> headers)
      Specified by:
      requestBodyAndHeaders in interface org.apache.camel.ProducerTemplate
    • requestBodyAndHeaders

      public Object requestBodyAndHeaders(Object body, Map<String,Object> headers)
      Specified by:
      requestBodyAndHeaders in interface org.apache.camel.ProducerTemplate
    • requestBody

      public <T> T requestBody(Object body, Class<T> type)
      Specified by:
      requestBody in interface org.apache.camel.ProducerTemplate
    • requestBody

      public <T> T requestBody(org.apache.camel.Endpoint endpoint, Object body, Class<T> type)
      Specified by:
      requestBody in interface org.apache.camel.ProducerTemplate
    • requestBody

      public <T> T requestBody(String endpointUri, Object body, Class<T> type)
      Specified by:
      requestBody in interface org.apache.camel.ProducerTemplate
    • requestBodyAndHeader

      public <T> T requestBodyAndHeader(org.apache.camel.Endpoint endpoint, Object body, String header, Object headerValue, Class<T> type)
      Specified by:
      requestBodyAndHeader in interface org.apache.camel.ProducerTemplate
    • requestBodyAndHeader

      public <T> T requestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue, Class<T> type)
      Specified by:
      requestBodyAndHeader in interface org.apache.camel.ProducerTemplate
    • requestBodyAndHeaders

      public <T> T requestBodyAndHeaders(String endpointUri, Object body, Map<String,Object> headers, Class<T> type)
      Specified by:
      requestBodyAndHeaders in interface org.apache.camel.ProducerTemplate
    • requestBodyAndHeaders

      public <T> T requestBodyAndHeaders(org.apache.camel.Endpoint endpoint, Object body, Map<String,Object> headers, Class<T> type)
      Specified by:
      requestBodyAndHeaders in interface org.apache.camel.ProducerTemplate
    • sendBody

      public void sendBody(Object body)
      Specified by:
      sendBody in interface org.apache.camel.ProducerTemplate
    • send

      public org.apache.camel.Exchange send(org.apache.camel.Exchange exchange)
      Specified by:
      send in interface org.apache.camel.ProducerTemplate
    • send

      public org.apache.camel.Exchange send(org.apache.camel.Processor processor)
      Specified by:
      send in interface org.apache.camel.ProducerTemplate
    • sendBodyAndHeader

      public void sendBodyAndHeader(Object body, String header, Object headerValue)
      Specified by:
      sendBodyAndHeader in interface org.apache.camel.ProducerTemplate
    • sendBodyAndProperty

      public void sendBodyAndProperty(Object body, String property, Object propertyValue)
      Specified by:
      sendBodyAndProperty in interface org.apache.camel.ProducerTemplate
    • sendBodyAndHeaders

      public void sendBodyAndHeaders(Object body, Map<String,Object> headers)
      Specified by:
      sendBodyAndHeaders in interface org.apache.camel.ProducerTemplate
    • getCamelContext

      public org.apache.camel.CamelContext getCamelContext()
      Specified by:
      getCamelContext in interface org.apache.camel.ProducerTemplate
    • getDefaultEndpoint

      public org.apache.camel.Endpoint getDefaultEndpoint()
      Specified by:
      getDefaultEndpoint in interface org.apache.camel.ProducerTemplate
    • setDefaultEndpoint

      public void setDefaultEndpoint(org.apache.camel.Endpoint defaultEndpoint)
      Specified by:
      setDefaultEndpoint in interface org.apache.camel.ProducerTemplate
    • setDefaultEndpointUri

      public void setDefaultEndpointUri(String endpointUri)
      Sets the default endpoint to use if none is specified
      Specified by:
      setDefaultEndpointUri in interface org.apache.camel.ProducerTemplate
    • createBodyAndHeaderProcessor

      protected org.apache.camel.Processor createBodyAndHeaderProcessor(Object body, String header, Object headerValue)
    • createBodyAndHeaders

      protected org.apache.camel.Processor createBodyAndHeaders(Object body, Map<String,Object> headers)
    • createBodyAndPropertyProcessor

      protected org.apache.camel.Processor createBodyAndPropertyProcessor(Object body, String property, Object propertyValue)
    • createSetBodyProcessor

      protected org.apache.camel.Processor createSetBodyProcessor(Object body)
    • createCompletionFunction

      protected Function<org.apache.camel.Exchange,org.apache.camel.Exchange> createCompletionFunction(org.apache.camel.spi.Synchronization onCompletion)
    • resolveMandatoryEndpoint

      protected org.apache.camel.Endpoint resolveMandatoryEndpoint(String endpointUri)
    • getMandatoryDefaultEndpoint

      protected org.apache.camel.Endpoint getMandatoryDefaultEndpoint()
    • extractResultBody

      protected Object extractResultBody(org.apache.camel.Exchange result)
    • extractResultBody

      protected Object extractResultBody(org.apache.camel.Exchange result, org.apache.camel.ExchangePattern pattern)
    • setExecutorService

      public void setExecutorService(ExecutorService executorService)
      Specified by:
      setExecutorService in interface org.apache.camel.ProducerTemplate
    • asyncSend

      public CompletableFuture<org.apache.camel.Exchange> asyncSend(String uri, org.apache.camel.Exchange exchange)
      Specified by:
      asyncSend in interface org.apache.camel.ProducerTemplate
    • asyncSend

      public CompletableFuture<org.apache.camel.Exchange> asyncSend(String uri, org.apache.camel.Processor processor)
      Specified by:
      asyncSend in interface org.apache.camel.ProducerTemplate
    • asyncSendBody

      public CompletableFuture<Object> asyncSendBody(String uri, Object body)
      Specified by:
      asyncSendBody in interface org.apache.camel.ProducerTemplate
    • asyncRequestBody

      public CompletableFuture<Object> asyncRequestBody(String uri, Object body)
      Specified by:
      asyncRequestBody in interface org.apache.camel.ProducerTemplate
    • asyncRequestBody

      public <T> CompletableFuture<T> asyncRequestBody(String uri, Object body, Class<T> type)
      Specified by:
      asyncRequestBody in interface org.apache.camel.ProducerTemplate
    • asyncRequestBodyAndHeader

      public CompletableFuture<Object> asyncRequestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue)
      Specified by:
      asyncRequestBodyAndHeader in interface org.apache.camel.ProducerTemplate
    • asyncRequestBodyAndHeader

      public <T> CompletableFuture<T> asyncRequestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue, Class<T> type)
      Specified by:
      asyncRequestBodyAndHeader in interface org.apache.camel.ProducerTemplate
    • asyncRequestBodyAndHeaders

      public CompletableFuture<Object> asyncRequestBodyAndHeaders(String endpointUri, Object body, Map<String,Object> headers)
      Specified by:
      asyncRequestBodyAndHeaders in interface org.apache.camel.ProducerTemplate
    • asyncRequestBodyAndHeaders

      public <T> CompletableFuture<T> asyncRequestBodyAndHeaders(String endpointUri, Object body, Map<String,Object> headers, Class<T> type)
      Specified by:
      asyncRequestBodyAndHeaders in interface org.apache.camel.ProducerTemplate
    • extractFutureBody

      public <T> T extractFutureBody(Future<?> future, Class<T> type)
      Specified by:
      extractFutureBody in interface org.apache.camel.ProducerTemplate
    • extractFutureBody

      public <T> T extractFutureBody(Future<?> future, long timeout, TimeUnit unit, Class<T> type) throws TimeoutException
      Specified by:
      extractFutureBody in interface org.apache.camel.ProducerTemplate
      Throws:
      TimeoutException
    • asyncRequestBody

      public CompletableFuture<Object> asyncRequestBody(org.apache.camel.Endpoint endpoint, Object body)
      Specified by:
      asyncRequestBody in interface org.apache.camel.ProducerTemplate
    • asyncRequestBody

      public <T> CompletableFuture<T> asyncRequestBody(org.apache.camel.Endpoint endpoint, Object body, Class<T> type)
      Specified by:
      asyncRequestBody in interface org.apache.camel.ProducerTemplate
    • asyncRequestBodyAndHeader

      public CompletableFuture<Object> asyncRequestBodyAndHeader(org.apache.camel.Endpoint endpoint, Object body, String header, Object headerValue)
      Specified by:
      asyncRequestBodyAndHeader in interface org.apache.camel.ProducerTemplate
    • asyncRequestBody

      protected <T> CompletableFuture<T> asyncRequestBody(org.apache.camel.Endpoint endpoint, org.apache.camel.Processor processor, Class<T> type)
    • asyncRequestBodyAndHeader

      public <T> CompletableFuture<T> asyncRequestBodyAndHeader(org.apache.camel.Endpoint endpoint, Object body, String header, Object headerValue, Class<T> type)
      Specified by:
      asyncRequestBodyAndHeader in interface org.apache.camel.ProducerTemplate
    • asyncRequestBodyAndHeaders

      public CompletableFuture<Object> asyncRequestBodyAndHeaders(org.apache.camel.Endpoint endpoint, Object body, Map<String,Object> headers)
      Specified by:
      asyncRequestBodyAndHeaders in interface org.apache.camel.ProducerTemplate
    • asyncRequestBodyAndHeaders

      public <T> CompletableFuture<T> asyncRequestBodyAndHeaders(org.apache.camel.Endpoint endpoint, Object body, Map<String,Object> headers, Class<T> type)
      Specified by:
      asyncRequestBodyAndHeaders in interface org.apache.camel.ProducerTemplate
    • asyncSend

      public CompletableFuture<org.apache.camel.Exchange> asyncSend(org.apache.camel.Endpoint endpoint, org.apache.camel.Exchange exchange)
      Specified by:
      asyncSend in interface org.apache.camel.ProducerTemplate
    • asyncSend

      public CompletableFuture<org.apache.camel.Exchange> asyncSend(org.apache.camel.Endpoint endpoint, org.apache.camel.Processor processor)
      Specified by:
      asyncSend in interface org.apache.camel.ProducerTemplate
    • asyncSendBody

      public CompletableFuture<Object> asyncSendBody(org.apache.camel.Endpoint endpoint, Object body)
      Specified by:
      asyncSendBody in interface org.apache.camel.ProducerTemplate
    • asyncRequestBody

      protected CompletableFuture<Object> asyncRequestBody(org.apache.camel.Endpoint endpoint, org.apache.camel.Processor processor)
    • asyncRequestBody

      protected CompletableFuture<Object> asyncRequestBody(org.apache.camel.Endpoint endpoint, org.apache.camel.Processor processor, org.apache.camel.Processor resultProcessor)
    • asyncRequest

      protected CompletableFuture<org.apache.camel.Exchange> asyncRequest(org.apache.camel.Endpoint endpoint, org.apache.camel.Processor processor, org.apache.camel.Processor resultProcessor)
    • asyncSend

      protected CompletableFuture<org.apache.camel.Exchange> asyncSend(org.apache.camel.Endpoint endpoint, org.apache.camel.ExchangePattern pattern, org.apache.camel.Processor processor, org.apache.camel.Processor resultProcessor)
    • asyncSendExchange

      protected CompletableFuture<org.apache.camel.Exchange> asyncSendExchange(org.apache.camel.Endpoint endpoint, org.apache.camel.ExchangePattern pattern, org.apache.camel.Processor processor, org.apache.camel.Processor resultProcessor, org.apache.camel.Exchange inExchange)
    • doBuild

      protected void doBuild() throws Exception
      Overrides:
      doBuild in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doInit

      protected void doInit() throws Exception
      Overrides:
      doInit in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doShutdown

      protected void doShutdown() throws Exception
      Overrides:
      doShutdown in class org.apache.camel.support.service.BaseService
      Throws:
      Exception