public abstract class ScheduledMessageInjector<C extends ScheduledIngressConfig,R extends FetchReference<T>,T> extends Object implements org.quartz.Job
Job
interface and handle the
functionality of the scheduled job. This class should be a stateless class since for each job iteration new instance
of this class will be created to execute the job functionality.
In each job iteration this will fetch the existing resources list in the configured location and inject each resource one by one as a new message to the engine. Before injecting a new message to the engine this will compare the existing polling count and execution count to decide whether is it allowed to proceed based on the configured concurrent polling count and concurrent execution count. Each resource will be processed after getting lock for that resource id to make sure that resource won't be picked up and process by another polling thread.
Modifier and Type | Field and Description |
---|---|
(package private) static String |
INGRESS_CONFIG_KEY |
(package private) static String |
JOB_CONTEXT_KEY |
(package private) static String |
LISTENER_KEY |
protected Logger |
logger |
(package private) static String |
MESSAGE_RECEIVER_KEY |
(package private) static String |
POLLING_EXECUTOR_KEY |
Constructor and Description |
---|
ScheduledMessageInjector() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
afterProcess(C config,
T fetchRef,
XMessageContext mc)
Abstract method to handle all the tasks which should be executed after successfully injecting the polling resource
to the engine as a new message
|
void |
execute(org.quartz.JobExecutionContext ctx) |
protected abstract List<R> |
fetchList(C config)
Abstract method to implement the logic for fetching the existing list of resources in the configured location for
the scheduled job.
|
protected abstract XMessageContext |
fetchMessage(C config,
T fetchRef)
Abstract method to construct a new message from the given
FetchReference object. |
protected abstract void |
onExecutionLimitExceeded(XMessageContext messageContext,
C config,
R fetchReference)
Abstract method which is exposed as an extension point to handle execution count exceed event for polling message
injectors.
|
protected abstract void |
onFailure(C config,
T fetchRef,
XMessageContext mc,
Throwable t)
Abstract method to handle all the tasks which should be executed after getting any failures while trying to inject
the resources as a new message to the engine
|
static final String INGRESS_CONFIG_KEY
static final String LISTENER_KEY
static final String JOB_CONTEXT_KEY
static final String MESSAGE_RECEIVER_KEY
static final String POLLING_EXECUTOR_KEY
protected final Logger logger
public final void execute(org.quartz.JobExecutionContext ctx) throws org.quartz.JobExecutionException
execute
in interface org.quartz.Job
org.quartz.JobExecutionException
protected abstract void onExecutionLimitExceeded(XMessageContext messageContext, C config, R fetchReference)
messageContext
- prepared message context for the polling iterationconfig
- connector config for the polling connectorfetchReference
- reference for the current polling resourceprotected abstract List<R> fetchList(C config)
config
- connector configuration of the relevant polling connectorFetchReference
objects in the configured locationprotected abstract XMessageContext fetchMessage(C config, T fetchRef)
FetchReference
object. Implementation of this
method should be specific to the type of the fetched resource.config
- connector configuration of the relevant polling connectorfetchRef
- the reference for the resource to be fetched and injected to the engine after constructing a new messageprotected abstract void afterProcess(C config, T fetchRef, XMessageContext mc)
config
- connector configuration of the relevant polling connectorfetchRef
- the reference for the resource which has been fetched and injected to the enginemc
- the message context constructed and injected to the engine from the polling resourceprotected abstract void onFailure(C config, T fetchRef, XMessageContext mc, Throwable t)
config
- connector configuration of the relevant polling connectorfetchRef
- the reference for the resource which has been tried to fetch and inject to the enginemc
- the message context constructed and injected to the engine from the polling resourcet
- the throwable object related to the failureCopyright © 2016–2019 AdroitLogic. All rights reserved.