public class ActivityWorker extends Object implements WorkerBase
| Constructor and Description |
|---|
ActivityWorker(AmazonSimpleWorkflow service,
String domain,
String taskListToPoll) |
| Modifier and Type | Method and Description |
|---|---|
List<ActivityType> |
addActivitiesImplementation(Object activitiesImplementation) |
List<ActivityType> |
addActivitiesImplementation(Object activitiesImplementation,
DataConverter converter) |
List<ActivityType> |
addActivitiesImplementations(Iterable<Object> activitiesImplementations) |
List<ActivityType> |
addActivitiesImplementations(Iterable<Object> activitiesImplementations,
DataConverter dataConverter) |
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
Iterable<Object> |
getActivitiesImplementations() |
ActivityImplementation |
getActivityImplementation(ActivityType activityType) |
Iterable<ActivityType> |
getActivityTypesToRegister() |
DataConverter |
getDataConverter() |
String |
getDomain() |
long |
getDomainRetentionPeriodInDays() |
String |
getIdentity() |
int |
getMaximumPollRateIntervalMilliseconds() |
double |
getMaximumPollRatePerSecond() |
double |
getPollBackoffCoefficient() |
long |
getPollBackoffInitialInterval() |
long |
getPollBackoffMaximumInterval() |
int |
getPollThreadCount() |
AmazonSimpleWorkflow |
getService() |
int |
getTaskExecutorThreadPoolSize() |
String |
getTaskListToPoll()
Task list name that given worker polls for tasks.
|
Thread.UncaughtExceptionHandler |
getUncaughtExceptionHandler() |
boolean |
isDisableServiceShutdownOnStop() |
boolean |
isDisableTypeRegistrationOnStart() |
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()
Allow new poll requests.
|
void |
setActivitiesImplementations(Iterable<Object> activitiesImplementations) |
void |
setDataConverter(DataConverter dataConverter) |
void |
setDisableServiceShutdownOnStop(boolean disableServiceShutdownOnStop)
When set to false (which is default) at the beginning of the worker
shutdown
AmazonSimpleWorkflow.shutdown() is called. |
void |
setDisableTypeRegistrationOnStart(boolean disableTypeRegistrationOnStart)
When set to true disables types registration on start even if
SkipTypeRegistration is not specified. |
void |
setDomainRetentionPeriodInDays(long days)
Value of DomainRetentionPeriodInDays parameter passed to
AmazonSimpleWorkflow.registerDomain(com.amazonaws.services.simpleworkflow.model.RegisterDomainRequest) call. |
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 |
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 |
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 |
setTaskExecutorThreadPoolSize(int taskExecutorThreadPoolSize) |
void |
setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
Handler notified about poll request and other unexpected failures.
|
void |
shutdown() |
boolean |
shutdownAndAwaitTermination(long timeout,
TimeUnit unit) |
void |
shutdownNow() |
void |
start() |
void |
suspendPolling()
Do not make new poll requests.
|
String |
toString() |
public ActivityWorker(AmazonSimpleWorkflow service, String domain, String taskListToPoll)
public void setActivitiesImplementations(Iterable<Object> activitiesImplementations) throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException
public List<ActivityType> addActivitiesImplementations(Iterable<Object> activitiesImplementations) throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException
public List<ActivityType> addActivitiesImplementations(Iterable<Object> activitiesImplementations, DataConverter dataConverter) throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException
public List<ActivityType> addActivitiesImplementation(Object activitiesImplementation) throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException
public List<ActivityType> addActivitiesImplementation(Object activitiesImplementation, DataConverter converter) throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException
public Iterable<ActivityType> getActivityTypesToRegister()
public ActivityImplementation getActivityImplementation(ActivityType activityType)
public DataConverter getDataConverter()
public void setDataConverter(DataConverter dataConverter)
public int getTaskExecutorThreadPoolSize()
public void setTaskExecutorThreadPoolSize(int taskExecutorThreadPoolSize)
public boolean shutdownAndAwaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
shutdownAndAwaitTermination in interface WorkerLifecycleInterruptedExceptionpublic void shutdownNow()
shutdownNow in interface WorkerLifecyclepublic AmazonSimpleWorkflow getService()
getService in interface WorkerBasepublic String getDomain()
getDomain in interface WorkerBasepublic boolean isRegisterDomain()
isRegisterDomain in interface WorkerBasepublic boolean awaitTermination(long timeout,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface WorkerLifecycleInterruptedExceptionpublic void setRegisterDomain(boolean registerDomain)
WorkerBasefalse.
When enabled #setDomainRetentionPeriodInDays(Long) property is
required.setRegisterDomain in interface WorkerBasepublic long getDomainRetentionPeriodInDays()
getDomainRetentionPeriodInDays in interface WorkerBasepublic void setDomainRetentionPeriodInDays(long days)
WorkerBaseAmazonSimpleWorkflow.registerDomain(com.amazonaws.services.simpleworkflow.model.RegisterDomainRequest) call. Required when
WorkerBase.isRegisterDomain() is true.setDomainRetentionPeriodInDays in interface WorkerBasepublic String getTaskListToPoll()
WorkerBasegetTaskListToPoll in interface WorkerBasepublic double getMaximumPollRatePerSecond()
getMaximumPollRatePerSecond in interface WorkerBasepublic void setMaximumPollRatePerSecond(double maximumPollRatePerSecond)
WorkerBasesetMaximumPollRatePerSecond in interface WorkerBaseWorkerBase.setMaximumPollRateIntervalMilliseconds(int)public int getMaximumPollRateIntervalMilliseconds()
getMaximumPollRateIntervalMilliseconds in interface WorkerBasepublic void setMaximumPollRateIntervalMilliseconds(int maximumPollRateIntervalMilliseconds)
WorkerBasesetMaximumPollRateIntervalMilliseconds in interface WorkerBaseWorkerBase.setMaximumPollRatePerSecond(double)public Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()
getUncaughtExceptionHandler in interface WorkerBasepublic void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
WorkerBasesetUncaughtExceptionHandler in interface WorkerBasepublic String getIdentity()
getIdentity in interface WorkerBasepublic void setIdentity(String identity)
WorkerBasesetIdentity in interface WorkerBaseidentity - maximum size is 256 characters.public long getPollBackoffInitialInterval()
getPollBackoffInitialInterval in interface WorkerBasepublic void setPollBackoffInitialInterval(long backoffInitialInterval)
WorkerBasesetPollBackoffInitialInterval in interface WorkerBasebackoffInitialInterval - the interval between failure and the first retry. Default is
100.public long getPollBackoffMaximumInterval()
getPollBackoffMaximumInterval in interface WorkerBasepublic void setPollBackoffMaximumInterval(long backoffMaximumInterval)
setPollBackoffMaximumInterval in interface WorkerBasebackoffMaximumInterval - maximum interval between poll request retries. Default is
60000 (one minute).WorkerBase.setPollBackoffInitialInterval(long)public boolean isDisableServiceShutdownOnStop()
isDisableServiceShutdownOnStop in interface WorkerBasepublic void setDisableServiceShutdownOnStop(boolean disableServiceShutdownOnStop)
WorkerBaseAmazonSimpleWorkflow.shutdown() 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 WorkerBasepublic double getPollBackoffCoefficient()
getPollBackoffCoefficient in interface WorkerBasepublic void setPollBackoffCoefficient(double backoffCoefficient)
setPollBackoffCoefficient in interface WorkerBasebackoffCoefficient - 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 WorkerBasepublic void setPollThreadCount(int threadCount)
WorkerBaseActivityWorker two separate threads pools are used. One for
polling and another one for executing activities. The size of the
activity execution thread pool is defined through
setTaskExecutorThreadPoolSize(int).setPollThreadCount in interface WorkerBasepublic void setDisableTypeRegistrationOnStart(boolean disableTypeRegistrationOnStart)
WorkerBaseSkipTypeRegistration is not specified. Types still can be
registered by calling WorkerBase.registerTypesToPoll().setDisableTypeRegistrationOnStart in interface WorkerBasepublic boolean isDisableTypeRegistrationOnStart()
isDisableTypeRegistrationOnStart in interface WorkerBasepublic void registerTypesToPoll()
WorkerBaseregisterTypesToPoll in interface WorkerBaseWorkerBase.setDisableTypeRegistrationOnStart(boolean)public void start()
start in interface WorkerLifecyclepublic void shutdown()
shutdown in interface WorkerLifecyclepublic boolean isRunning()
isRunning in interface WorkerBasepublic void suspendPolling()
SuspendablesuspendPolling in interface Suspendablepublic void resumePolling()
SuspendableresumePolling in interface Suspendable