T - the generic type for the generated message's payloadA - the generic type for the generated message's attributespublic abstract class PollingSource<T,A> extends Source<T,A>
Source which automatically handles polling, idempotency and watermarking. As a result of the poll,
many items can be obtained and dispatched for execution, each one as a standalone Message.
The SDK will automatically add a <scheduling-strategy> parameter and the runtime will use that strategy
to automatically schedule executions of the poll(PollContext) method. The PollContext will be used to
dispatch the obtained items, optionally enabling features like watermarking and idempotency.
| Modifier and Type | Field and Description |
|---|---|
static String |
IDS_ON_UPDATED_WATERMARK_OS_NAME_SUFFIX |
static String |
OS_NAME_MASK |
static String |
OS_NAME_PREFIX |
static String |
RECENTLY_PROCESSED_IDS_OS_NAME_SUFFIX |
static String |
UPDATED_WATERMARK_ITEM_OS_KEY |
static String |
WATERMARK_ITEM_OS_KEY |
static String |
WATERMARK_OS_NAME_SUFFIX |
| Constructor and Description |
|---|
PollingSource() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
doStart()
Implement this method to perform custom starting logic.
|
protected abstract void |
doStop()
Implement this method to perform custom stopping logic.
|
abstract void |
onRejectedItem(Result<T,A> result,
SourceCallbackContext callbackContext)
If one of the items dispatched through
PollContext.accept(Consumer) were rejected (either by watermarking,
idempotency, server overload, etc.), this method is to be used to released any resources associated to the given
result. |
void |
onStart(SourceCallback<T,A> sourceCallback)
This method will be invoked by the runtime to make the source start
producing messages.
|
void |
onStop()
This method will be invoked by the runtime to make the source stop producing messages.
|
abstract void |
poll(PollContext<T,A> pollContext)
This method is responsible for obtaining the items to be dispatched and communicate them through the
pollContext
using the PollContext.accept(Consumer) method. |
public static final String OS_NAME_PREFIX
public static final String OS_NAME_MASK
public static final String WATERMARK_OS_NAME_SUFFIX
public static final String RECENTLY_PROCESSED_IDS_OS_NAME_SUFFIX
public static final String IDS_ON_UPDATED_WATERMARK_OS_NAME_SUFFIX
public static final String WATERMARK_ITEM_OS_KEY
public static final String UPDATED_WATERMARK_ITEM_OS_KEY
public final void onStart(SourceCallback<T,A> sourceCallback) throws org.mule.runtime.api.exception.MuleException
Each generated message will be passed back to the runtime through the
given sourceCallback for processing.
This method should throw an exception if the source fails to start, but
any other exception encountered during the process of generating messages,
should be communicated to the runtime through the SourceCallback.onConnectionException(ConnectionException)}
method.
Only the runtime should invoke this method. Do not do it manually
onStart in class Source<T,A>sourceCallback - a SourceCallbackorg.mule.runtime.api.exception.MuleException - If the source fails to start.public final void onStop()
This method should not fail. Any exceptions found during the stop process should be logged and correctly handled by the source, but after invoking this method the source must:
Only the runtime should invoke this method. Do not do it manually
protected abstract void doStart()
throws org.mule.runtime.api.exception.MuleException
org.mule.runtime.api.exception.MuleExceptionprotected abstract void doStop()
public abstract void poll(PollContext<T,A> pollContext)
pollContext
using the PollContext.accept(Consumer) method.
See the PollContext documentation for more information on how to use it and the options available
pollContext - the polling contextpublic abstract void onRejectedItem(Result<T,A> result, SourceCallbackContext callbackContext)
PollContext.accept(Consumer) were rejected (either by watermarking,
idempotency, server overload, etc.), this method is to be used to released any resources associated to the given
result.result - a rejected itemcallbackContext - the associated SourceCallbackContextCopyright © 2020 MuleSoft, Inc.. All rights reserved.