Interface PollContext<T,A>
- Type Parameters:
T- the generic type for the generated message's payloadA- the generic type for the generated message's attributes
@MinMuleVersion("4.1")
@NoImplement
public interface PollContext<T,A>
Contains context associated to each polling execution, and allows to dispatch items for execution through the
accept(Consumer) method. Depending on how the supplied PollContext.PollItem is configured, the runtime will automatically
apply watermarking, idempotency, etc.- Since:
- 1.1
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn item obtained through a pollstatic enumThe possible outcomes of submiting an item for processing through theaccept(Consumer)method -
Method Summary
Modifier and TypeMethodDescriptionaccept(Consumer<PollContext.PollItem<T, A>> consumer) Submits an item to be processed.The current watermark value at the moment of starting the poll.booleanWhether the source has received the stopping signal.voidonConnectionException(org.mule.runtime.api.connection.ConnectionException e) Equivalent toSourceCallback.onConnectionException(ConnectionException).voidsetWatermarkComparator(Comparator<? extends Serializable> comparator) Allows to set a customComparatorto evaluate watermark values.
-
Method Details
-
accept
Submits an item to be processed. The runtime will supply aPollContext.PollItemin which theResultand other options will be set- Parameters:
consumer- aConsumerof aPollContext.PollItem- Returns:
- a
PollContext.PollItemStatus
-
getWatermark
Optional<Serializable> getWatermark()The current watermark value at the moment of starting the poll. If watermarking is disabled or this is the first execution, the value will beOptional.empty()- Returns:
- an optional watermark value
-
isSourceStopping
boolean isSourceStopping()Whether the source has received the stopping signal. It is a good practice to check for this condition before engaging on a time consuming task.- Returns:
- Whether the source has received the stopping signal or not.
-
setWatermarkComparator
Allows to set a customComparatorto evaluate watermark values. If not specified andComparablevalues are used as watermarks, then this method is only optional. Otherwise, exceptions will be thrown if a proper comparator was not set.- Parameters:
comparator- a customComparator- Throws:
IllegalArgumentException- if thecomparatorisnull
-
onConnectionException
void onConnectionException(org.mule.runtime.api.connection.ConnectionException e) Equivalent toSourceCallback.onConnectionException(ConnectionException). Should be used in the same circumstances- Parameters:
e- aConnectionException
-