Package org.apache.camel.component.ahc
Class AhcEndpoint
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultEndpoint
-
- org.apache.camel.component.ahc.AhcEndpoint
-
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.AsyncEndpoint
,org.apache.camel.CamelContextAware
,org.apache.camel.Endpoint
,org.apache.camel.IsSingleton
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.HasId
,org.apache.camel.spi.HeaderFilterStrategyAware
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
@UriEndpoint(firstVersion="2.8.0", scheme="ahc", title="Async HTTP Client (AHC)", syntax="ahc:httpUri", producerOnly=true, category=HTTP, lenientProperties=true) public class AhcEndpoint extends org.apache.camel.support.DefaultEndpoint implements org.apache.camel.AsyncEndpoint, org.apache.camel.spi.HeaderFilterStrategyAware
Call external HTTP services using Async Http Client.
-
-
Constructor Summary
Constructors Constructor Description AhcEndpoint(String endpointUri, AhcComponent component, URI httpUri)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.asynchttpclient.AsyncHttpClient
createClient(org.asynchttpclient.AsyncHttpClientConfig config)
org.apache.camel.Consumer
createConsumer(org.apache.camel.Processor processor)
org.apache.camel.Producer
createProducer()
protected void
doStart()
protected void
doStop()
AhcBinding
getBinding()
int
getBufferSize()
org.asynchttpclient.AsyncHttpClient
getClient()
org.asynchttpclient.AsyncHttpClientConfig
getClientConfig()
Map<String,Object>
getClientConfigOptions()
Map<String,Object>
getClientConfigRealmOptions()
AhcComponent
getComponent()
org.apache.camel.http.base.cookie.CookieHandler
getCookieHandler()
org.apache.camel.spi.HeaderFilterStrategy
getHeaderFilterStrategy()
URI
getHttpUri()
org.apache.camel.support.jsse.SSLContextParameters
getSslContextParameters()
boolean
isBridgeEndpoint()
boolean
isConnectionClose()
boolean
isLenientProperties()
boolean
isThrowExceptionOnFailure()
boolean
isTransferException()
void
setBinding(AhcBinding binding)
To use a customAhcBinding
which allows to control how to bind between AHC and Camel.void
setBridgeEndpoint(boolean bridgeEndpoint)
If the option is true, then the Exchange.HTTP_URI header is ignored, and use the endpoint's URI for request.void
setBufferSize(int bufferSize)
The initial in-memory buffer size used when transferring data between Camel and AHC Client.void
setClient(org.asynchttpclient.AsyncHttpClient client)
To use a customAsyncHttpClient
void
setClientConfig(org.asynchttpclient.AsyncHttpClientConfig clientConfig)
To configure the AsyncHttpClient to use a custom com.ning.http.client.AsyncHttpClientConfig instance.void
setClientConfigOptions(Map<String,Object> clientConfigOptions)
To configure the AsyncHttpClientConfig using the key/values from the Map.void
setClientConfigRealmOptions(Map<String,Object> clientConfigRealmOptions)
To configure the AsyncHttpClientConfig Realm using the key/values from the Map.void
setConnectionClose(boolean connectionClose)
Define if the Connection Close header has to be added to HTTP Request.void
setCookieHandler(org.apache.camel.http.base.cookie.CookieHandler cookieHandler)
Configure a cookie handler to maintain a HTTP sessionvoid
setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
To use a custom HeaderFilterStrategy to filter header to and from Camel message.void
setHttpUri(URI httpUri)
The URI to use such as http://hostname:port/pathvoid
setSslContextParameters(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters)
Reference to a org.apache.camel.support.jsse.SSLContextParameters in the Registry.void
setThrowExceptionOnFailure(boolean throwExceptionOnFailure)
Option to disable throwing the AhcOperationFailedException in case of failed responses from the remote server.void
setTransferException(boolean transferException)
If enabled and an Exchange failed processing on the consumer side, and if the caused Exception was send back serialized in the response as a application/x-java-serialized-object content type (for example using Jetty or Servlet Camel components).-
Methods inherited from class org.apache.camel.support.DefaultEndpoint
configureConsumer, configurePollingConsumer, configureProperties, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, doInit, equals, getCamelContext, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isPollingConsumerBlockWhenFull, isSingleton, isSynchronous, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerQueueSize, setProperties, setSynchronous, toString
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.camel.Endpoint
configureProperties, createAsyncProducer, createExchange, createExchange, createPollingConsumer, getCamelContext, getEndpointBaseUri, getEndpointKey, getEndpointUri, isSingletonProducer, setCamelContext
-
-
-
-
Constructor Detail
-
AhcEndpoint
public AhcEndpoint(String endpointUri, AhcComponent component, URI httpUri)
-
-
Method Detail
-
getComponent
public AhcComponent getComponent()
- Overrides:
getComponent
in classorg.apache.camel.support.DefaultEndpoint
-
createProducer
public org.apache.camel.Producer createProducer() throws Exception
- Specified by:
createProducer
in interfaceorg.apache.camel.Endpoint
- Throws:
Exception
-
createConsumer
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception
- Specified by:
createConsumer
in interfaceorg.apache.camel.Endpoint
- Throws:
Exception
-
isLenientProperties
public boolean isLenientProperties()
- Specified by:
isLenientProperties
in interfaceorg.apache.camel.Endpoint
- Overrides:
isLenientProperties
in classorg.apache.camel.support.DefaultEndpoint
-
getClient
public org.asynchttpclient.AsyncHttpClient getClient()
-
setClient
public void setClient(org.asynchttpclient.AsyncHttpClient client)
To use a customAsyncHttpClient
-
getClientConfig
public org.asynchttpclient.AsyncHttpClientConfig getClientConfig()
-
setClientConfig
public void setClientConfig(org.asynchttpclient.AsyncHttpClientConfig clientConfig)
To configure the AsyncHttpClient to use a custom com.ning.http.client.AsyncHttpClientConfig instance.
-
getHttpUri
public URI getHttpUri()
-
setHttpUri
public void setHttpUri(URI httpUri)
The URI to use such as http://hostname:port/path
-
getBinding
public AhcBinding getBinding()
-
setBinding
public void setBinding(AhcBinding binding)
To use a customAhcBinding
which allows to control how to bind between AHC and Camel.
-
getHeaderFilterStrategy
public org.apache.camel.spi.HeaderFilterStrategy getHeaderFilterStrategy()
- Specified by:
getHeaderFilterStrategy
in interfaceorg.apache.camel.spi.HeaderFilterStrategyAware
-
setHeaderFilterStrategy
public void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
To use a custom HeaderFilterStrategy to filter header to and from Camel message.- Specified by:
setHeaderFilterStrategy
in interfaceorg.apache.camel.spi.HeaderFilterStrategyAware
-
isBridgeEndpoint
public boolean isBridgeEndpoint()
-
setBridgeEndpoint
public void setBridgeEndpoint(boolean bridgeEndpoint)
If the option is true, then the Exchange.HTTP_URI header is ignored, and use the endpoint's URI for request. You may also set the throwExceptionOnFailure to be false to let the AhcProducer send all the fault response back.
-
isThrowExceptionOnFailure
public boolean isThrowExceptionOnFailure()
-
setThrowExceptionOnFailure
public void setThrowExceptionOnFailure(boolean throwExceptionOnFailure)
Option to disable throwing the AhcOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code.
-
isTransferException
public boolean isTransferException()
-
setTransferException
public void setTransferException(boolean transferException)
If enabled and an Exchange failed processing on the consumer side, and if the caused Exception was send back serialized in the response as a application/x-java-serialized-object content type (for example using Jetty or Servlet Camel components). On the producer side the exception will be deserialized and thrown as is, instead of the AhcOperationFailedException. The caused exception is required to be serialized. This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from the request to Java and that can be a potential security risk.
-
getSslContextParameters
public org.apache.camel.support.jsse.SSLContextParameters getSslContextParameters()
-
setSslContextParameters
public void setSslContextParameters(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters)
Reference to a org.apache.camel.support.jsse.SSLContextParameters in the Registry. This reference overrides any configured SSLContextParameters at the component level. See Using the JSSE Configuration Utility. Note that configuring this option will override any SSL/TLS configuration options provided through the clientConfig option at the endpoint or component level.
-
getBufferSize
public int getBufferSize()
-
setBufferSize
public void setBufferSize(int bufferSize)
The initial in-memory buffer size used when transferring data between Camel and AHC Client.
-
setClientConfigOptions
public void setClientConfigOptions(Map<String,Object> clientConfigOptions)
To configure the AsyncHttpClientConfig using the key/values from the Map.
-
setClientConfigRealmOptions
public void setClientConfigRealmOptions(Map<String,Object> clientConfigRealmOptions)
To configure the AsyncHttpClientConfig Realm using the key/values from the Map.
-
isConnectionClose
public boolean isConnectionClose()
-
setConnectionClose
public void setConnectionClose(boolean connectionClose)
Define if the Connection Close header has to be added to HTTP Request. This parameter is false by default
-
getCookieHandler
public org.apache.camel.http.base.cookie.CookieHandler getCookieHandler()
-
setCookieHandler
public void setCookieHandler(org.apache.camel.http.base.cookie.CookieHandler cookieHandler)
Configure a cookie handler to maintain a HTTP session
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classorg.apache.camel.support.DefaultEndpoint
- Throws:
Exception
-
createClient
protected org.asynchttpclient.AsyncHttpClient createClient(org.asynchttpclient.AsyncHttpClientConfig config)
-
-