@ComponentProfile(summary="Allows clustered single service processing.",
tag="service,clustering,vertx")
public class VertxService
extends ServiceImp
implements io.vertx.core.Handler<io.vertx.core.eventbus.Message<VertXMessage>>, ConsumerEventListener, ServiceWrapper
A clustered service that allows you to farm out the service processing to a random instance of this service in your cluster.
Clusters are managed and discovered by Hazelcast. To create a cluster you simply need to have multiple instances of this service
either in different workflows or different instances of Interlok with the same vertx-id on each instance of the service. It is
recommended that you explicitly configure setClusterId(String); if it is not expliclty configured, then we default to
ServiceImp.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 will be sent to ALL instances in the cluster. Likewise if you select "single" then a
single random service instance will process the message.
Additionally if you choose "single" once the service instance has finished running the original service will receive the
processed message as a reply.
When an instance of this service receives a message to process, it will run the wrapped-service (which may also be a service-list). But no further services in the workflow will be run.
Should you choose to send each message to only one instance in the cluster then the original service will receive a reply and run
the wrapped reply-service (which may also be a service-list).
And should the service(s) fail you can configure a ProcessingExceptionHandler.
Do note however, that any reply expected will not be waited for.
If there are services to be run after this service in the originally consumed workflow, they will run without waiting for the
reply.
You can choose the cluster to send messages to by configuring the target-component-id. The value of which will match the cluster
name (unique-id) of any clustered service.
Any message will be sent to the named cluster, which may also include this very instance of the service if this service shares
the same unique-id as the other clustered service instances.
In the adapter configuration file this class is aliased as clustered-service which is the preferred alternative to the fully qualified classname when building your configuration.
logCONFIRMATION_ID_KEY| Constructor and Description |
|---|
VertxService() |
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getLookupName, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setLookupName, setUniqueIdclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetUniqueIdcontinueOnFailure, isBranching, setUniqueIdcreateName, createQualifier, isTrackingEndpointchangeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentStategetUniqueIdclose, initgetLookupNamepublic void doService(AdaptrisMessage msg) throws ServiceException
doService in interface ServiceServiceExceptionpublic void handleMessageReply(io.vertx.core.eventbus.Message<java.lang.Object> result)
handleMessageReply in interface ConsumerEventListenerpublic void prepare()
throws CoreException
prepare in interface ComponentLifecycleExtensionCoreExceptionprotected void initService()
throws CoreException
initService in class ServiceImpCoreExceptionpublic void start()
throws CoreException
start in interface ComponentLifecyclestart in class ServiceImpCoreExceptionpublic void stop()
stop in interface ComponentLifecyclestop in class ServiceImppublic void consumerStarted()
consumerStarted in interface ConsumerEventListenerprotected void closeService()
closeService in class ServiceImppublic Service getService()
public void setService(Service service)
public void handle(io.vertx.core.eventbus.Message<VertXMessage> event)
handle in interface io.vertx.core.Handler<io.vertx.core.eventbus.Message<VertXMessage>>public VertXMessageTranslator getVertXMessageTranslator()
public void setVertXMessageTranslator(VertXMessageTranslator vertXMessageTranslator)
public DataInputParameter<java.lang.String> getTargetComponentId()
public void setTargetComponentId(DataInputParameter<java.lang.String> targetComponentId)
public SendMode.Mode getTargetSendMode()
public void setTargetSendMode(SendMode.Mode targetSendMode)
public Service getReplyService()
public void setReplyService(Service replyService)
public ProcessingExceptionHandler getReplyServiceExceptionHandler()
public void setReplyServiceExceptionHandler(ProcessingExceptionHandler replyServiceExcecptionHandler)
public java.lang.String getClusterId()
getClusterId in interface ConsumerEventListenerpublic void setClusterId(java.lang.String vertxId)
vertxId - if not configured, defaults to ServiceImp.getUniqueId()public Service[] wrappedServices()
wrappedServices in interface ServiceWrapperprotected int maxThreads()
public java.lang.Integer getMaxThreads()
public void setMaxThreads(java.lang.Integer maxThreads)
public VertxProperties getVertxProperties()
public void setVertxProperties(VertxProperties vertxProperties)