@ComponentProfile(summary="A workflow that allows clustered processing of services.",
tag="workflow,clustering,vertx")
public class VertxWorkflow
extends StandardWorkflowImpl
implements io.vertx.core.Handler<io.vertx.core.eventbus.Message<VertXMessage>>, ConsumerEventListener, ExpiryListener<VertXMessage>
Since there are no guarantees about which instance will process the message, this workflow will not support the new
AdaptrisMessageListener.onAdaptrisMessage(AdaptrisMessage, Consumer) method; any callbacks requested by the
consumer will be ignored
Clusters are managed and discovered by Hazelcast. To create a cluster you simply need to have multiple instances of this workflow
either in different channels or different instances of Interlok with the same vertx-id on each instance of the workflow.It is
recommended that you explicitly configure setClusterId(String); if it is not expliclty configured, then we default to
WorkflowImp.getUniqueId().
There are two modes of clustering; "all" and "single" (default), configured with the target-send-mode option.
If you select "all", then each message consumed by this workflow will be sent to ALL instances in the cluster. Likewise if you
select "single" then a single random workflow instance will process the message.
Additionally if you choose "single" once the worklfow instance has finished running their service-list the original worklfow will
receive the processed message as a reply. If you have a configured producer on the original workflow then the reply message will
be produced.
No reply is received if you choose "all" as the target send mode. Any producers you need must therefore be configured in the
service-list of each instance in the cluster.
You can choose the cluster to send any consumed messages to by configuring the target-component-id. The value of which will match
the cluster name (unique-id) of any clustered workflow.
Any consumed message will be sent to the named cluster, which may also include the workflow that consumed the message if that
workflow also shares the same unique-id as the other clustered workflow instances.
Every message consumed as mentioned earlier is sent to the cluster for processing and then for a potential reply, which means
that any consumed message is immediately acknowledged before the processing is complete. To stop the workflows consumer from
consuming too many messages waiting for processing we can set the maximum number of messages to be queued up for processing. The
default value is 10, but can be changed with the configuration option queue-capacity.
Finally, should a service in the clustered instance fail, further services will not be run, unless you configure continue-on-error = true. The default value being false. When all services have executed successfully or one has failed therefore stopping service execution, the reply is sent back to the original consumed workflow. Once the reply has been received it will check to see if any services failed. If any services have failed then the message-error-handler will run.
In the adapter configuration file this class is aliased as clustered-workflow which is the preferred alternative to the fully qualified classname when building your configuration.
eventHandler, log, startTime, stopTimePREVIOUS_GUID_KEY, WORKFLOW_ID_KEY| Constructor and Description |
|---|
VertxWorkflow() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
closeWorkflow() |
void |
consumerStarted() |
protected boolean |
continueOnError() |
java.lang.String |
getClusterId() |
java.lang.Boolean |
getContinueOnError() |
TimeInterval |
getItemExpiryTimeout() |
java.lang.Integer |
getMaxThreads() |
java.lang.Integer |
getQueueCapacity() |
DataInputParameter<java.lang.String> |
getTargetComponentId() |
SendMode.Mode |
getTargetSendMode() |
VertXMessageTranslator |
getVertXMessageTranslator() |
VertxProperties |
getVertxProperties() |
void |
handle(io.vertx.core.eventbus.Message<VertXMessage> event) |
void |
handleMessageReply(io.vertx.core.eventbus.Message<java.lang.Object> result) |
protected void |
initialiseWorkflow() |
void |
itemExpired(VertXMessage item) |
protected int |
maxThreads() |
void |
onAdaptrisMessage(AdaptrisMessage msg,
java.util.function.Consumer<AdaptrisMessage> success) |
void |
onVertxMessage(io.vertx.core.eventbus.Message<VertXMessage> xMessage) |
protected void |
prepareWorkflow() |
protected void |
resubmitMessage(AdaptrisMessage msg) |
void |
setClusterId(java.lang.String vertxId)
Sets the ID that will be registered with vertx.
|
void |
setContinueOnError(java.lang.Boolean continueOnError) |
void |
setItemExpiryTimeout(TimeInterval itemExpiryTimeout) |
void |
setMaxThreads(java.lang.Integer maxThreads) |
void |
setQueueCapacity(java.lang.Integer queueCapacity) |
void |
setTargetComponentId(DataInputParameter<java.lang.String> targetComponentId) |
void |
setTargetSendMode(SendMode.Mode targetSendMode) |
void |
setVertXMessageTranslator(VertXMessageTranslator vertXMessageTranslator) |
void |
setVertxProperties(VertxProperties vertxProperties) |
protected void |
startWorkflow() |
protected void |
stopWorkflow() |
protected java.lang.String |
targetComponentId(VertXMessage vertxMessage) |
handleMessageaddConsumeLocation, addInterceptor, changeState, channelUnavailableWait, close, copyExceptionHeaders, disableMessageCount, doProduce, friendlyName, getChannelUnavailableWaitInterval, getComments, getConsumer, getDisableDefaultMessageCount, getInterceptors, getLogPayload, getMessageErrorHandler, getMessageLogger, getProduceExceptionHandler, getProducer, getSendEvents, getServiceCollection, getUniqueId, handleBadMessage, handleBadMessage, handleChannelUnavailable, handleProduceException, init, lastStartTime, lastStopTime, logSuccess, messageLogger, obtainChannel, obtainWorkflowId, prepare, processingStart, registerActiveMsgErrorHandler, registerChannel, registerEventHandler, requestClose, requestInit, requestStart, requestStop, retrieveActiveMsgErrorHandler, retrieveComponentState, sendMessageLifecycleEvent, setChannelUnavailableWaitInterval, setComments, setConsumer, setDisableDefaultMessageCount, setInterceptors, setLogPayload, setMessageErrorHandler, setMessageLogger, setProduceExceptionHandler, setProducer, setSendEvents, setServiceCollection, setUniqueId, start, stop, workflowEnd, workflowStartclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetUniqueIdonAdaptrisMessagepublic void onAdaptrisMessage(AdaptrisMessage msg, java.util.function.Consumer<AdaptrisMessage> success)
onAdaptrisMessage in interface AdaptrisMessageListeneronAdaptrisMessage in class StandardWorkflowImplprotected void resubmitMessage(AdaptrisMessage msg)
resubmitMessage in class StandardWorkflowImplpublic void onVertxMessage(io.vertx.core.eventbus.Message<VertXMessage> xMessage)
protected void initialiseWorkflow()
throws CoreException
initialiseWorkflow in class StandardWorkflowImplCoreExceptionprotected void prepareWorkflow()
throws CoreException
prepareWorkflow in class StandardWorkflowImplCoreExceptionprotected void startWorkflow()
throws CoreException
startWorkflow in class StandardWorkflowImplCoreExceptionpublic void consumerStarted()
consumerStarted in interface ConsumerEventListenerpublic void handleMessageReply(io.vertx.core.eventbus.Message<java.lang.Object> result)
handleMessageReply in interface ConsumerEventListenerpublic void handle(io.vertx.core.eventbus.Message<VertXMessage> event)
handle in interface io.vertx.core.Handler<io.vertx.core.eventbus.Message<VertXMessage>>public void itemExpired(VertXMessage item)
itemExpired in interface ExpiryListener<VertXMessage>protected void stopWorkflow()
stopWorkflow in class StandardWorkflowImplprotected void closeWorkflow()
closeWorkflow in class StandardWorkflowImplpublic java.lang.String getClusterId()
getClusterId in interface ConsumerEventListenerpublic void setClusterId(java.lang.String vertxId)
vertxId - if not configured, defaults to WorkflowImp.getUniqueId()public java.lang.Integer getQueueCapacity()
public void setQueueCapacity(java.lang.Integer queueCapacity)
public VertXMessageTranslator getVertXMessageTranslator()
public void setVertXMessageTranslator(VertXMessageTranslator vertXMessageTranslator)
protected java.lang.String targetComponentId(VertXMessage vertxMessage) throws InterlokException
InterlokExceptionprotected boolean continueOnError()
public java.lang.Boolean getContinueOnError()
public void setContinueOnError(java.lang.Boolean continueOnError)
public SendMode.Mode getTargetSendMode()
public void setTargetSendMode(SendMode.Mode targetSendMode)
public DataInputParameter<java.lang.String> getTargetComponentId()
public void setTargetComponentId(DataInputParameter<java.lang.String> targetComponentId)
public TimeInterval getItemExpiryTimeout()
public void setItemExpiryTimeout(TimeInterval itemExpiryTimeout)
protected int maxThreads()
public java.lang.Integer getMaxThreads()
public void setMaxThreads(java.lang.Integer maxThreads)
public VertxProperties getVertxProperties()
public void setVertxProperties(VertxProperties vertxProperties)