public final class TriggeredChannel extends Channel implements AdaptrisMessageListener, LicensedComponent
Workflows configured as part of a TriggeredChannel do not participate in the normal adapter lifecycle until such time as its trigger consumer consumes a message. At that point, the underlying connections and workflows are initialised, and started.
After starting the workflows, the channel blocks and waits for the workflows to terminate, so that it can accept the next
trigger. As a result of this behaviour, it only makes sense for the workflows to contain consumers that actively poll the
back-end system such as AdaptrisPollingConsumer
, rather than consumers that passively wait for activity. Failure to
follow these guidelines may lead to undefined behaviour.
Even when using an AdaptrisPollingConsumer
implementation the Poller
mechanism that should be
used should have a finite lifespan such as OneTimePoller
so that the workflows terminate as expected. If you opt not to
use a poller with a finite lifespan then behaviour may be undefined.
This type of channel also handles errors and events differently. A specific EventHandler may be specified to physically handle MessageLifecycleEvents that are created within the channel. If this is unspecified then the Adapter's EventHandler is used. The rationale behind this behaviour is to treat events as standard AdaptrisMessage objects which then allows message error handling logic to take place.
Any ProcessingExceptionHandler
implementation that is used with this Channel implementation must also
implement the TriggeredProcessor
interface, which simply allows this Channel to interrogate whether processing has been
completed by the component or not. This ensures that the channel is not stopped prior to any messages that need to be retried
from being retried, thus failing the messages before their time.
OneTimePoller
,
AdaptrisPollingConsumer
,
TriggeredProcessor
In the adapter configuration file this class is aliased as triggered-channel which is the preferred alternative to the fully qualified classname when building your configuration.
License Required: STANDARD
eventHandler, log, startTime, stopTime
Constructor and Description |
---|
TriggeredChannel()
Default Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
java.lang.String |
friendlyName() |
EventHandler |
getEventHandlerForMessages() |
AdaptrisMessageFactory |
getMessageFactory() |
Trigger |
getTrigger() |
void |
init() |
boolean |
isEnabled(License license) |
void |
onAdaptrisMessage(AdaptrisMessage msg) |
void |
prepare() |
void |
setEventHandlerForMessages(EventHandler eh) |
void |
setMessageFactory(AdaptrisMessageFactory f)
Set the message factory used when creating AdaptrisMessage.
|
void |
setTrigger(Trigger t) |
void |
start() |
void |
stop() |
changeState, getAutoStart, getComments, getConsumeConnection, getMessageErrorHandler, getProduceConnection, getUniqueId, getWorkflowList, hasUniqueId, isAvailable, lastStartTime, lastStopTime, registerActiveMsgErrorHandler, registerEventHandler, requestChildClose, requestChildInit, requestChildStart, requestChildStop, requestClose, requestInit, requestStart, requestStop, retrieveActiveMsgErrorHandler, retrieveComponentState, setAutoStart, setComments, setConsumeConnection, setMessageErrorHandler, setProduceConnection, setUniqueId, setWorkflowList, shouldStart, toggleAvailability
public TriggeredChannel()
RetryMessageErrorHandler
public void init() throws CoreException
init
in interface ComponentLifecycle
init
in class Channel
CoreException
ChannelList.init()
public void prepare() throws CoreException
prepare
in interface ComponentLifecycleExtension
prepare
in class Channel
CoreException
public void start() throws CoreException
start
in interface ComponentLifecycle
start
in class Channel
CoreException
ChannelList.start()
public void stop()
stop
in interface ComponentLifecycle
stop
in class Channel
ChannelList.stop()
public void close()
close
in interface ComponentLifecycle
close
in class Channel
ChannelList.close()
public boolean isEnabled(License license)
isEnabled
in interface LicensedComponent
public void onAdaptrisMessage(AdaptrisMessage msg)
onAdaptrisMessage
in interface AdaptrisMessageListener
AdaptrisMessageListener.onAdaptrisMessage(AdaptrisMessage)
public Trigger getTrigger()
public void setTrigger(Trigger t)
t
- the triggerComponentpublic AdaptrisMessageFactory getMessageFactory()
public void setMessageFactory(AdaptrisMessageFactory f)
f
- the messageFactory to setpublic EventHandler getEventHandlerForMessages()
public void setEventHandlerForMessages(EventHandler eh)
eh
- the eventHandlerForMessages to setpublic java.lang.String friendlyName()
friendlyName
in interface AdaptrisMessageListener