Package org.camunda.bpm.client.impl
Class ExternalTaskClientBuilderImpl
- java.lang.Object
-
- org.camunda.bpm.client.impl.ExternalTaskClientBuilderImpl
-
- All Implemented Interfaces:
ExternalTaskClientBuilder
public class ExternalTaskClientBuilderImpl extends java.lang.Object implements ExternalTaskClientBuilder
- Author:
- Tassilo Weidner
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Long
asyncResponseTimeout
protected BackoffStrategy
backoffStrategy
protected java.lang.String
baseUrl
protected java.lang.String
dateFormat
protected java.lang.String
defaultSerializationFormat
protected EngineClient
engineClient
protected java.util.List<ClientRequestInterceptor>
interceptors
protected boolean
isAutoFetchingEnabled
protected boolean
isBackoffStrategyDisabled
protected long
lockDuration
protected static ExternalTaskClientLogger
LOG
protected int
maxTasks
protected com.fasterxml.jackson.databind.ObjectMapper
objectMapper
protected TopicSubscriptionManager
topicSubscriptionManager
protected TypedValues
typedValues
protected boolean
usePriority
protected ValueMappers
valueMappers
protected java.lang.String
workerId
-
Constructor Summary
Constructors Constructor Description ExternalTaskClientBuilderImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExternalTaskClientBuilder
addInterceptor(ClientRequestInterceptor interceptor)
Adds an interceptor to change a request before it is sent to the http server.protected void
applyConfigurator(java.util.Map<java.lang.String,DataFormat> dataFormats, DataFormatConfigurator configurator)
protected void
applyConfigurators(java.util.Map<java.lang.String,DataFormat> dataFormats)
ExternalTaskClientBuilder
asyncResponseTimeout(long asyncResponseTimeout)
Asynchronous response (long polling) is enabled if a timeout is given.ExternalTaskClientBuilder
backoffStrategy(BackoffStrategy backoffStrategy)
Adds a custom strategy to the client for defining the org.camunda.bpm.client.backoff between two requests.ExternalTaskClientBuilder
baseUrl(java.lang.String baseUrl)
Base url of the Camunda BPM Platform REST API.ExternalTaskClient
build()
Bootstraps the Camunda clientjava.lang.String
checkHostname()
protected void
checkInterceptors()
ExternalTaskClientBuilder
dateFormat(java.lang.String dateFormat)
Specifies the date format to de-/serialize date variables.ExternalTaskClientBuilder
defaultSerializationFormat(java.lang.String defaultSerializationFormat)
Specifies the serialization format that is used to serialize objects when no specific format is requested.ExternalTaskClientBuilder
disableAutoFetching()
Disables immediate fetching for external tasks after callingExternalTaskClientBuilder.build()
to bootstrap the client.ExternalTaskClientBuilder
disableBackoffStrategy()
Disables the client-side backoff strategy.protected java.lang.Long
getAsyncResponseTimeout()
protected BackoffStrategy
getBackoffStrategy()
java.lang.String
getBaseUrl()
java.lang.String
getDateFormat()
java.lang.String
getDefaultSerializationFormat()
EngineClient
getEngineClient()
java.lang.String
getHostname()
protected java.util.List<ClientRequestInterceptor>
getInterceptors()
protected long
getLockDuration()
protected int
getMaxTasks()
com.fasterxml.jackson.databind.ObjectMapper
getObjectMapper()
TypedValues
getTypedValues()
ValueMappers
getValueMappers()
protected java.lang.String
getWorkerId()
protected void
initBaseUrl()
protected void
initEngineClient()
protected void
initObjectMapper()
protected void
initTopicSubscriptionManager()
protected void
initVariableMappers()
protected void
initWorkerId()
protected boolean
isAutoFetchingEnabled()
ExternalTaskClientBuilder
lockDuration(long lockDuration)
protected void
lookupCustomDataFormats(java.util.Map<java.lang.String,DataFormat> dataFormats)
protected java.util.Map<java.lang.String,DataFormat>
lookupDataFormats()
protected void
lookupProvider(java.util.Map<java.lang.String,DataFormat> dataFormats, DataFormatProvider provider)
ExternalTaskClientBuilder
maxTasks(int maxTasks)
Specifies the maximum amount of tasks that can be fetched within one request.protected java.lang.String
sanitizeUrl(java.lang.String url)
ExternalTaskClientBuilder
usePriority(boolean usePriority)
Specifies whether tasks should be fetched based on their priority or arbitrarily.ExternalTaskClientBuilder
workerId(java.lang.String workerId)
A custom worker id the Workflow Engine is aware of.
-
-
-
Field Detail
-
LOG
protected static final ExternalTaskClientLogger LOG
-
baseUrl
protected java.lang.String baseUrl
-
workerId
protected java.lang.String workerId
-
maxTasks
protected int maxTasks
-
usePriority
protected boolean usePriority
-
asyncResponseTimeout
protected java.lang.Long asyncResponseTimeout
-
lockDuration
protected long lockDuration
-
defaultSerializationFormat
protected java.lang.String defaultSerializationFormat
-
dateFormat
protected java.lang.String dateFormat
-
objectMapper
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
-
valueMappers
protected ValueMappers valueMappers
-
typedValues
protected TypedValues typedValues
-
engineClient
protected EngineClient engineClient
-
topicSubscriptionManager
protected TopicSubscriptionManager topicSubscriptionManager
-
interceptors
protected java.util.List<ClientRequestInterceptor> interceptors
-
isAutoFetchingEnabled
protected boolean isAutoFetchingEnabled
-
backoffStrategy
protected BackoffStrategy backoffStrategy
-
isBackoffStrategyDisabled
protected boolean isBackoffStrategyDisabled
-
-
Method Detail
-
baseUrl
public ExternalTaskClientBuilder baseUrl(java.lang.String baseUrl)
Description copied from interface:ExternalTaskClientBuilder
Base url of the Camunda BPM Platform REST API. This information is mandatory.- Specified by:
baseUrl
in interfaceExternalTaskClientBuilder
- Parameters:
baseUrl
- of the Camunda BPM Platform REST API- Returns:
- the builder
-
workerId
public ExternalTaskClientBuilder workerId(java.lang.String workerId)
Description copied from interface:ExternalTaskClientBuilder
A custom worker id the Workflow Engine is aware of. This information is optional. Note: make sure to choose a unique worker id If not given or null, a worker id is generated automatically which consists of the hostname as well as a random and unique 128 bit string (UUID).- Specified by:
workerId
in interfaceExternalTaskClientBuilder
- Parameters:
workerId
- the Workflow Engine is aware of- Returns:
- the builder
-
addInterceptor
public ExternalTaskClientBuilder addInterceptor(ClientRequestInterceptor interceptor)
Description copied from interface:ExternalTaskClientBuilder
Adds an interceptor to change a request before it is sent to the http server. This information is optional.- Specified by:
addInterceptor
in interfaceExternalTaskClientBuilder
- Parameters:
interceptor
- which changes the request- Returns:
- the builder
-
maxTasks
public ExternalTaskClientBuilder maxTasks(int maxTasks)
Description copied from interface:ExternalTaskClientBuilder
Specifies the maximum amount of tasks that can be fetched within one request. This information is optional. Default is 10.- Specified by:
maxTasks
in interfaceExternalTaskClientBuilder
- Parameters:
maxTasks
- which are supposed to be fetched within one request- Returns:
- the builder
-
usePriority
public ExternalTaskClientBuilder usePriority(boolean usePriority)
Description copied from interface:ExternalTaskClientBuilder
Specifies whether tasks should be fetched based on their priority or arbitrarily. This information is optional. Default istrue
.- Specified by:
usePriority
in interfaceExternalTaskClientBuilder
- Parameters:
usePriority
- when fetching and locking tasks- Returns:
- the builder
-
asyncResponseTimeout
public ExternalTaskClientBuilder asyncResponseTimeout(long asyncResponseTimeout)
Description copied from interface:ExternalTaskClientBuilder
Asynchronous response (long polling) is enabled if a timeout is given. Specifies the maximum waiting time for the response of fetched and locked external tasks. The response is performed immediately, if external tasks are available in the moment of the request. This information is optional. Unless a timeout is given, fetch and lock responses are synchronous.- Specified by:
asyncResponseTimeout
in interfaceExternalTaskClientBuilder
- Parameters:
asyncResponseTimeout
- of fetched and locked external tasks in milliseconds- Returns:
- the builder
-
lockDuration
public ExternalTaskClientBuilder lockDuration(long lockDuration)
- Specified by:
lockDuration
in interfaceExternalTaskClientBuilder
- Parameters:
lockDuration
-- in milliseconds to lock the external tasks
- must be greater than zero
- the default lock duration is 20 seconds (20,000 milliseconds)
- is overridden by the lock duration configured on a topic subscription
- Returns:
- the builder
-
disableAutoFetching
public ExternalTaskClientBuilder disableAutoFetching()
Description copied from interface:ExternalTaskClientBuilder
Disables immediate fetching for external tasks after callingExternalTaskClientBuilder.build()
to bootstrap the client. To start fetchingExternalTaskClient.start()
must be called.- Specified by:
disableAutoFetching
in interfaceExternalTaskClientBuilder
- Returns:
- the builder
-
backoffStrategy
public ExternalTaskClientBuilder backoffStrategy(BackoffStrategy backoffStrategy)
Description copied from interface:ExternalTaskClientBuilder
Adds a custom strategy to the client for defining the org.camunda.bpm.client.backoff between two requests. This information is optional. By defaultExponentialBackoffStrategy
is applied.- Specified by:
backoffStrategy
in interfaceExternalTaskClientBuilder
- Parameters:
backoffStrategy
- which realizes a custom org.camunda.bpm.client.backoff strategy- Returns:
- the builder
-
disableBackoffStrategy
public ExternalTaskClientBuilder disableBackoffStrategy()
Description copied from interface:ExternalTaskClientBuilder
Disables the client-side backoff strategy. On invocation, the configuration optionExternalTaskClientBuilder.backoffStrategy(org.camunda.bpm.client.backoff.BackoffStrategy)
is ignored. NOTE: Please bear in mind that disabling the client-side backoff can lead to heavy load situations on engine side. To avoid this, please specify an appropriateExternalTaskClientBuilder.asyncResponseTimeout(long)
.- Specified by:
disableBackoffStrategy
in interfaceExternalTaskClientBuilder
- Returns:
- the builder
-
defaultSerializationFormat
public ExternalTaskClientBuilder defaultSerializationFormat(java.lang.String defaultSerializationFormat)
Description copied from interface:ExternalTaskClientBuilder
Specifies the serialization format that is used to serialize objects when no specific format is requested. This option defaults to application/json.- Specified by:
defaultSerializationFormat
in interfaceExternalTaskClientBuilder
- Parameters:
defaultSerializationFormat
- serialization format to be used- Returns:
- the builder
-
dateFormat
public ExternalTaskClientBuilder dateFormat(java.lang.String dateFormat)
Description copied from interface:ExternalTaskClientBuilder
Specifies the date format to de-/serialize date variables.- Specified by:
dateFormat
in interfaceExternalTaskClientBuilder
- Parameters:
dateFormat
- date format to be used- Returns:
- the builder
-
build
public ExternalTaskClient build()
Description copied from interface:ExternalTaskClientBuilder
Bootstraps the Camunda client- Specified by:
build
in interfaceExternalTaskClientBuilder
- Returns:
- the builder
-
initBaseUrl
protected void initBaseUrl()
-
sanitizeUrl
protected java.lang.String sanitizeUrl(java.lang.String url)
-
initWorkerId
protected void initWorkerId()
-
checkInterceptors
protected void checkInterceptors()
-
initObjectMapper
protected void initObjectMapper()
-
initVariableMappers
protected void initVariableMappers()
-
initEngineClient
protected void initEngineClient()
-
initTopicSubscriptionManager
protected void initTopicSubscriptionManager()
-
lookupDataFormats
protected java.util.Map<java.lang.String,DataFormat> lookupDataFormats()
-
lookupCustomDataFormats
protected void lookupCustomDataFormats(java.util.Map<java.lang.String,DataFormat> dataFormats)
-
lookupProvider
protected void lookupProvider(java.util.Map<java.lang.String,DataFormat> dataFormats, DataFormatProvider provider)
-
applyConfigurators
protected void applyConfigurators(java.util.Map<java.lang.String,DataFormat> dataFormats)
-
applyConfigurator
protected void applyConfigurator(java.util.Map<java.lang.String,DataFormat> dataFormats, DataFormatConfigurator configurator)
-
checkHostname
public java.lang.String checkHostname()
-
getHostname
public java.lang.String getHostname() throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
-
getBaseUrl
public java.lang.String getBaseUrl()
-
getWorkerId
protected java.lang.String getWorkerId()
-
getInterceptors
protected java.util.List<ClientRequestInterceptor> getInterceptors()
-
getMaxTasks
protected int getMaxTasks()
-
getAsyncResponseTimeout
protected java.lang.Long getAsyncResponseTimeout()
-
getLockDuration
protected long getLockDuration()
-
isAutoFetchingEnabled
protected boolean isAutoFetchingEnabled()
-
getBackoffStrategy
protected BackoffStrategy getBackoffStrategy()
-
getDefaultSerializationFormat
public java.lang.String getDefaultSerializationFormat()
-
getDateFormat
public java.lang.String getDateFormat()
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-
getValueMappers
public ValueMappers getValueMappers()
-
getTypedValues
public TypedValues getTypedValues()
-
getEngineClient
public EngineClient getEngineClient()
-
-