public class SpringActivityWorker extends Object implements WorkerBase, org.springframework.context.SmartLifecycle
Modifier and Type | Field and Description |
---|---|
protected long |
terminationTimeoutSeconds |
Constructor and Description |
---|
SpringActivityWorker() |
SpringActivityWorker(GenericActivityWorker genericWorker) |
SpringActivityWorker(software.amazon.awssdk.services.swf.SwfClient service,
String domain,
String taskListToPoll) |
SpringActivityWorker(software.amazon.awssdk.services.swf.SwfClient service,
String domain,
String taskListToPoll,
SimpleWorkflowClientConfig config) |
Modifier and Type | Method and Description |
---|---|
List<ActivityType> |
addActivitiesImplementation(Object activitiesImplementation) |
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
Iterable<Object> |
getActivitiesImplementations() |
SimpleWorkflowClientConfig |
getClientConfig() |
DataConverter |
getDataConverter() |
String |
getDomain() |
long |
getDomainRetentionPeriodInDays() |
int |
getExecuteThreadCount() |
String |
getIdentity() |
int |
getMaximumPollRateIntervalMilliseconds() |
double |
getMaximumPollRatePerSecond() |
MetricsRegistry |
getMetricsRegistry() |
int |
getPhase() |
double |
getPollBackoffCoefficient() |
long |
getPollBackoffInitialInterval() |
long |
getPollBackoffMaximumInterval() |
int |
getPollThreadCount() |
software.amazon.awssdk.services.swf.SwfClient |
getService() |
String |
getTaskListToPoll()
Task list name that given worker polls for tasks.
|
long |
getTerminationTimeoutSeconds() |
Thread.UncaughtExceptionHandler |
getUncaughtExceptionHandler() |
boolean |
gracefulShutdown(long timeout,
TimeUnit unit) |
boolean |
isAllowCoreThreadTimeOut() |
boolean |
isAutoStartup() |
boolean |
isDisableAutoStartup() |
boolean |
isDisableServiceShutdownOnStop() |
boolean |
isDisableTypeRegistrationOnStart() |
boolean |
isPollingSuspended()
Check suspension status
|
boolean |
isRegisterDomain() |
boolean |
isRunning() |
void |
registerTypesToPoll()
Try to register every type (activity or workflow depending on worker)
that are configured with the worker.
|
void |
resumePolling()
Alias to setPollingSuspended(false)
|
void |
setActivitiesImplementations(Iterable<Object> activitiesImplementations) |
void |
setAllowCoreThreadTimeOut(boolean allowCoreThreadTimeOut)
When set to true allows the task execution threads to terminate
if they have been idle for 1 minute.
|
void |
setDataConverter(DataConverter dataConverter) |
void |
setDisableAutoStartup(boolean disableAutoStartup) |
void |
setDisableServiceShutdownOnStop(boolean disableServiceShutdownOnStop)
When set to false (which is default) at the beginning of the worker
shutdown
SdkAutoCloseable.close() is called. |
void |
setDisableTypeRegistrationOnStart(boolean disableTypeRegistrationOnStart)
When set to true disables types registration on start even if
SkipTypeRegistration is not specified. |
void |
setDomain(String domain) |
void |
setDomainRetentionPeriodInDays(long domainRetentionPeriodInDays)
Value of DomainRetentionPeriodInDays parameter passed to
SwfClient.registerDomain(software.amazon.awssdk.services.swf.model.RegisterDomainRequest) call. |
void |
setExecuteThreadCount(int threadCount)
Defines how many concurrent threads are used by the given worker to poll
the specified task list.
|
void |
setIdentity(String identity)
Set the identity that worker specifies in the poll requests.
|
void |
setMaximumPollRateIntervalMilliseconds(int maximumPollRateIntervalMilliseconds)
The sliding window interval used to measure the poll rate.
|
void |
setMaximumPollRatePerSecond(double maximumPollRatePerSecond)
Maximum number of poll request to the task list per second allowed.
|
void |
setMetricsRegistry(MetricsRegistry factory) |
void |
setPhase(int startPhase) |
void |
setPollBackoffCoefficient(double backoffCoefficient) |
void |
setPollBackoffInitialInterval(long backoffInitialInterval)
Failed poll requests are retried after an interval defined by an
exponential backoff algorithm.
|
void |
setPollBackoffMaximumInterval(long backoffMaximumInterval) |
void |
setPollingSuspended(boolean flag)
If set to
true stop making any poll requests. |
void |
setPollThreadCount(int threadCount)
Defines how many concurrent threads are used by the given worker to poll
the specified task list.
|
void |
setRegisterDomain(boolean registerDomain)
Should domain be registered on startup.
|
void |
setService(software.amazon.awssdk.services.swf.SwfClient service) |
void |
setTaskListToPoll(String taskListToPoll) |
void |
setTerminationTimeoutSeconds(long terminationTimeoutSeconds) |
void |
setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
Handler notified about poll request and other unexpected failures.
|
void |
shutdown() |
void |
shutdownAndAwaitTermination() |
boolean |
shutdownAndAwaitTermination(long timeout,
TimeUnit unit) |
void |
shutdownNow() |
void |
start() |
void |
stop() |
void |
stop(Runnable callback) |
void |
stopNow() |
void |
suspendPolling()
Alias to setPollingSuspended(true)
|
String |
toString() |
public SpringActivityWorker()
public SpringActivityWorker(software.amazon.awssdk.services.swf.SwfClient service, String domain, String taskListToPoll)
public SpringActivityWorker(software.amazon.awssdk.services.swf.SwfClient service, String domain, String taskListToPoll, SimpleWorkflowClientConfig config)
public SpringActivityWorker(GenericActivityWorker genericWorker)
public SimpleWorkflowClientConfig getClientConfig()
getClientConfig
in interface WorkerBase
public software.amazon.awssdk.services.swf.SwfClient getService()
getService
in interface WorkerBase
public void setService(software.amazon.awssdk.services.swf.SwfClient service)
public String getDomain()
getDomain
in interface WorkerBase
public void setDomain(String domain)
public boolean isRegisterDomain()
isRegisterDomain
in interface WorkerBase
public void setRegisterDomain(boolean registerDomain)
WorkerBase
false
.
When enabled WorkerBase.setDomainRetentionPeriodInDays(long)
property is
required.setRegisterDomain
in interface WorkerBase
registerDomain
- true if domain should be registeredpublic long getDomainRetentionPeriodInDays()
getDomainRetentionPeriodInDays
in interface WorkerBase
public void setDomainRetentionPeriodInDays(long domainRetentionPeriodInDays)
WorkerBase
SwfClient.registerDomain(software.amazon.awssdk.services.swf.model.RegisterDomainRequest)
call. Required when
WorkerBase.isRegisterDomain()
is true
.setDomainRetentionPeriodInDays
in interface WorkerBase
domainRetentionPeriodInDays
- Days to retain domain historypublic String getTaskListToPoll()
WorkerBase
getTaskListToPoll
in interface WorkerBase
public void setTaskListToPoll(String taskListToPoll)
public DataConverter getDataConverter()
public void setDataConverter(DataConverter dataConverter)
public double getMaximumPollRatePerSecond()
getMaximumPollRatePerSecond
in interface WorkerBase
public void setMaximumPollRatePerSecond(double maximumPollRatePerSecond)
WorkerBase
setMaximumPollRatePerSecond
in interface WorkerBase
maximumPollRatePerSecond
- - Maximum polls allowed per secondWorkerBase.setMaximumPollRateIntervalMilliseconds(int)
public int getMaximumPollRateIntervalMilliseconds()
getMaximumPollRateIntervalMilliseconds
in interface WorkerBase
public void setMaximumPollRateIntervalMilliseconds(int maximumPollRateIntervalMilliseconds)
WorkerBase
setMaximumPollRateIntervalMilliseconds
in interface WorkerBase
maximumPollRateIntervalMilliseconds
- - interval in milliseconds for rate limitingWorkerBase.setMaximumPollRatePerSecond(double)
public String getIdentity()
getIdentity
in interface WorkerBase
public void setIdentity(String identity)
WorkerBase
setIdentity
in interface WorkerBase
identity
- maximum size is 256 characters.public Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()
getUncaughtExceptionHandler
in interface WorkerBase
public void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
WorkerBase
setUncaughtExceptionHandler
in interface WorkerBase
uncaughtExceptionHandler
- - handler for processing uncaught exceptionspublic long getPollBackoffInitialInterval()
getPollBackoffInitialInterval
in interface WorkerBase
public void setPollBackoffInitialInterval(long backoffInitialInterval)
WorkerBase
setPollBackoffInitialInterval
in interface WorkerBase
backoffInitialInterval
- the interval between failure and the first retry. Default is
100.public long getPollBackoffMaximumInterval()
getPollBackoffMaximumInterval
in interface WorkerBase
public void setPollBackoffMaximumInterval(long backoffMaximumInterval)
setPollBackoffMaximumInterval
in interface WorkerBase
backoffMaximumInterval
- maximum interval between poll request retries. Default is
60000 (one minute).WorkerBase.setPollBackoffInitialInterval(long)
public double getPollBackoffCoefficient()
getPollBackoffCoefficient
in interface WorkerBase
public void setPollBackoffCoefficient(double backoffCoefficient)
setPollBackoffCoefficient
in interface WorkerBase
backoffCoefficient
- coefficient that defines how fast retry interval grows in case
of poll request failures. Default is 2.0.WorkerBase.setPollBackoffInitialInterval(long)
public int getPollThreadCount()
getPollThreadCount
in interface WorkerBase
public void setPollThreadCount(int threadCount)
WorkerBase
WorkerBase.setExecuteThreadCount(int)
.setPollThreadCount
in interface WorkerBase
threadCount
- - number of concurrent polling threadspublic int getExecuteThreadCount()
getExecuteThreadCount
in interface WorkerBase
public void setExecuteThreadCount(int threadCount)
WorkerBase
setExecuteThreadCount
in interface WorkerBase
threadCount
- - number of task execution threadspublic boolean isDisableServiceShutdownOnStop()
isDisableServiceShutdownOnStop
in interface WorkerBase
public void setDisableServiceShutdownOnStop(boolean disableServiceShutdownOnStop)
WorkerBase
SdkAutoCloseable.close()
is called. It causes all
outstanding long poll request to disconnect. But also causes all future
request (for example activity completions) to SWF fail.setDisableServiceShutdownOnStop
in interface WorkerBase
disableServiceShutdownOnStop
- - flag to control service shutdownpublic boolean isAllowCoreThreadTimeOut()
isAllowCoreThreadTimeOut
in interface WorkerBase
public MetricsRegistry getMetricsRegistry()
getMetricsRegistry
in interface WorkerBase
public void setMetricsRegistry(MetricsRegistry factory)
setMetricsRegistry
in interface WorkerBase
public void setAllowCoreThreadTimeOut(boolean allowCoreThreadTimeOut)
WorkerBase
setAllowCoreThreadTimeOut
in interface WorkerBase
allowCoreThreadTimeOut
- - flag to enable thread timeoutpublic void suspendPolling()
Suspendable
suspendPolling
in interface Suspendable
public void resumePolling()
Suspendable
resumePolling
in interface Suspendable
public boolean isPollingSuspended()
Suspendable
isPollingSuspended
in interface Suspendable
public void setPollingSuspended(boolean flag)
Suspendable
true
stop making any poll requests. Outstanding long polls still can return
tasks after this method was called. Setting to false
enables polling.setPollingSuspended
in interface Suspendable
flag
- - boolean to control polling statepublic void start()
start
in interface WorkerLifecycle
start
in interface org.springframework.context.Lifecycle
public void stopNow()
public void shutdown()
shutdown
in interface WorkerLifecycle
public void shutdownNow()
shutdownNow
in interface WorkerLifecycle
public boolean shutdownAndAwaitTermination(long timeout, TimeUnit unit) throws InterruptedException
shutdownAndAwaitTermination
in interface WorkerLifecycle
InterruptedException
public void shutdownAndAwaitTermination() throws InterruptedException
InterruptedException
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
awaitTermination
in interface WorkerLifecycle
InterruptedException
public boolean gracefulShutdown(long timeout, TimeUnit unit) throws InterruptedException
gracefulShutdown
in interface WorkerLifecycle
InterruptedException
public void stop()
stop
in interface org.springframework.context.Lifecycle
public boolean isRunning()
isRunning
in interface WorkerBase
isRunning
in interface org.springframework.context.Lifecycle
public void setActivitiesImplementations(Iterable<Object> activitiesImplementations) throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException
public List<ActivityType> addActivitiesImplementation(Object activitiesImplementation) throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException
public void registerTypesToPoll()
WorkerBase
registerTypesToPoll
in interface WorkerBase
WorkerBase.setDisableTypeRegistrationOnStart(boolean)
public int getPhase()
getPhase
in interface org.springframework.context.Phased
getPhase
in interface org.springframework.context.SmartLifecycle
public void setPhase(int startPhase)
public boolean isAutoStartup()
isAutoStartup
in interface org.springframework.context.SmartLifecycle
public long getTerminationTimeoutSeconds()
public void setTerminationTimeoutSeconds(long terminationTimeoutSeconds)
public boolean isDisableAutoStartup()
public void setDisableAutoStartup(boolean disableAutoStartup)
public void setDisableTypeRegistrationOnStart(boolean disableTypeRegistrationOnStart)
WorkerBase
SkipTypeRegistration
is not specified. Types still can be
registered by calling WorkerBase.registerTypesToPoll()
.setDisableTypeRegistrationOnStart
in interface WorkerBase
disableTypeRegistrationOnStart
- - flag to disable type registrationpublic boolean isDisableTypeRegistrationOnStart()
isDisableTypeRegistrationOnStart
in interface WorkerBase
public void stop(Runnable callback)
stop
in interface org.springframework.context.SmartLifecycle
Copyright © 2025. All rights reserved.