public class JmsMatsFactory<Z> extends java.lang.Object implements MatsInterceptableMatsFactory, JmsMatsStatics, JmsMatsStartStoppable
Modifier and Type | Class and Description |
---|---|
static class |
JmsMatsFactory.CannotInstantiateClassException |
MatsFactory.ContextLocal, MatsFactory.FactoryConfig, MatsFactory.MatsFactoryWrapper, MatsFactory.MatsWrapper<T>
MatsInterceptable.MatsLoggingInterceptor, MatsInterceptable.MatsMetricsInterceptor
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
INTERCEPTOR_CLASS_MATS_LOGGING |
static java.lang.String |
INTERCEPTOR_CLASS_MATS_METRICS |
NO_CONFIG
EXTRA_GRACE_MILLIS, ILLEGAL_CALL_FLOWS, JMS_MSG_PROP_AUDIT, JMS_MSG_PROP_DISPATCH_TYPE, JMS_MSG_PROP_FROM, JMS_MSG_PROP_INITIALIZING_APP, JMS_MSG_PROP_INITIATOR_ID, JMS_MSG_PROP_MATS_MESSAGE_ID, JMS_MSG_PROP_MESSAGE_TYPE, JMS_MSG_PROP_TO, JMS_MSG_PROP_TRACE_ID, LOG_PREFIX, MAX_STACK_HEIGHT, MAX_TOTAL_CALL_NUMBER, MDC_MATS_APP_NAME, MDC_MATS_APP_VERSION, MDC_MATS_CALL_NUMBER, MDC_MATS_IN_MESSAGE_SYSTEM_ID, MDC_MATS_INIT, MDC_MATS_OUT_MATS_MESSAGE_ID, MDC_MATS_STAGE, MDC_MATS_STAGE_ID, MDC_TRACE_ID, NO_INVOCATION_POINT, RANDOM_ALPHABET, THREAD_PREFIX, TOTAL_JMS_MSG_PROPS_SIZE
Modifier and Type | Method and Description |
---|---|
void |
addInitiationInterceptor(MatsInitiateInterceptor initiateInterceptor) |
void |
addStageInterceptor(MatsStageInterceptor stageInterceptor) |
void |
close()
Method for Spring's default lifecycle - directly invokes
stop(30_000) . |
static <Z> JmsMatsFactory<Z> |
createMatsFactory_JmsAndJdbcTransactions(java.lang.String appName,
java.lang.String appVersion,
JmsMatsJmsSessionHandler jmsMatsJmsSessionHandler,
javax.sql.DataSource dataSource,
MatsSerializer<Z> matsSerializer) |
static <Z> JmsMatsFactory<Z> |
createMatsFactory_JmsOnlyTransactions(java.lang.String appName,
java.lang.String appVersion,
JmsMatsJmsSessionHandler jmsMatsJmsSessionHandler,
MatsSerializer<Z> matsSerializer) |
static <Z> JmsMatsFactory<Z> |
createMatsFactory(java.lang.String appName,
java.lang.String appVersion,
JmsMatsJmsSessionHandler jmsMatsJmsSessionHandler,
JmsMatsTransactionManager jmsMatsTransactionManager,
MatsSerializer<Z> matsSerializer) |
boolean |
equals(java.lang.Object o) |
java.util.List<JmsMatsStartStoppable> |
getChildrenStartStoppable()
Must be implemented to provide your children.
|
MatsInitiator |
getDefaultInitiator()
Gets or creates the default Initiator (whose name is 'default') from which to initiate new Mats processes, i.e.
|
java.util.Optional<MatsEndpoint<?,?>> |
getEndpoint(java.lang.String endpointId) |
java.util.List<MatsEndpoint<?,?>> |
getEndpoints() |
MatsFactory.FactoryConfig |
getFactoryConfig() |
<T extends MatsInitiateInterceptor> |
getInitiationInterceptor(java.lang.Class<T> interceptorClass) |
java.util.List<MatsInitiateInterceptor> |
getInitiationInterceptors() |
java.util.List<MatsInitiator> |
getInitiators() |
JmsMatsJmsSessionHandler |
getJmsMatsJmsSessionHandler() |
JmsMatsTransactionManager |
getJmsMatsTransactionManager() |
MatsSerializer<Z> |
getMatsSerializer() |
io.mats3.impl.jms.JmsMatsInitiator<Z> |
getOrCreateInitiator_internal(java.lang.String name) |
MatsInitiator |
getOrCreateInitiator(java.lang.String name)
Gets or creates a new Initiator from which to initiate new Mats processes, i.e.
|
<T extends MatsStageInterceptor> |
getStageInterceptor(java.lang.Class<T> interceptorClass) |
java.util.List<MatsStageInterceptor> |
getStageInterceptors() |
int |
hashCode() |
void |
holdEndpointsUntilFactoryIsStarted()
If this method is invoked before any endpoint is created, the endpoints will not start even though
MatsEndpoint.finishSetup() is invoked on them, but will wait till MatsFactory.start() is invoked on the
factory. This feature should be employed in most setups where the MATS endpoints might use other services or
components whose order of creation and initialization are difficult to fully control, e.g. |
java.lang.String |
idThis() |
boolean |
isHoldEndpointsUntilFactoryIsStarted() |
void |
removeInitiationInterceptor(MatsInitiateInterceptor initiateInterceptor) |
void |
removeStageInterceptor(MatsStageInterceptor stageInterceptor) |
void |
setDefaultKeepTrace(MatsInitiator.KeepTrace defaultKeepTrace)
Sets the default KeepTrace if the initiation doesn't set one itself.
|
<R,I> JmsMatsEndpoint<R,java.lang.Void,Z> |
single(java.lang.String endpointId,
java.lang.Class<R> replyClass,
java.lang.Class<I> incomingClass,
java.util.function.Consumer<? super MatsEndpoint.EndpointConfig<R,java.lang.Void>> endpointConfigLambda,
java.util.function.Consumer<? super MatsStage.StageConfig<R,java.lang.Void,I>> stageConfigLambda,
MatsEndpoint.ProcessSingleLambda<R,I> processor)
Variation of
#single(String, Class, Class, ProcessSingleLambda) that can be configured "on the fly". |
<R,I> MatsEndpoint<R,java.lang.Void> |
single(java.lang.String endpointId,
java.lang.Class<R> replyClass,
java.lang.Class<I> incomingClass,
MatsEndpoint.ProcessSingleLambda<R,I> processor)
Sets up a
MatsEndpoint that just contains one stage, useful for simple "request the full person data for
this/these personId(s)" scenarios. |
<R,S> JmsMatsEndpoint<R,S,Z> |
staged(java.lang.String endpointId,
java.lang.Class<R> replyClass,
java.lang.Class<S> stateClass)
Sets up a
MatsEndpoint on which you will add stages. |
<R,S> JmsMatsEndpoint<R,S,Z> |
staged(java.lang.String endpointId,
java.lang.Class<R> replyClass,
java.lang.Class<S> stateClass,
java.util.function.Consumer<? super MatsEndpoint.EndpointConfig<R,S>> endpointConfigLambda)
Variation of
MatsFactory.staged(String, Class, Class) that can be configured "on the fly". |
void |
start()
Starts all endpoints that has been created by this factory, by invoking
MatsEndpoint.start() on them. |
boolean |
stop(int gracefulShutdownMillis)
Stops all endpoints and initiators, by invoking
MatsEndpoint.stop(int) on all the endpoints, and
MatsInitiator.close() on all initiators that has been created by this factory. |
<S,I> JmsMatsEndpoint<java.lang.Void,S,Z> |
subscriptionTerminator(java.lang.String endpointId,
java.lang.Class<S> stateClass,
java.lang.Class<I> incomingClass,
java.util.function.Consumer<? super MatsEndpoint.EndpointConfig<java.lang.Void,S>> endpointConfigLambda,
java.util.function.Consumer<? super MatsStage.StageConfig<java.lang.Void,S,I>> stageConfigLambda,
MatsEndpoint.ProcessTerminatorLambda<S,I> processor)
Variation of
#subscriptionTerminator(String, Class, Class, ProcessTerminatorLambda) that can be
configured "on the fly", but notice that the concurrency of a SubscriptionTerminator is always 1. |
<S,I> JmsMatsEndpoint<java.lang.Void,S,Z> |
subscriptionTerminator(java.lang.String endpointId,
java.lang.Class<S> stateClass,
java.lang.Class<I> incomingClass,
MatsEndpoint.ProcessTerminatorLambda<S,I> processor)
Special kind of terminator that, in JMS-style terms, subscribes to a topic instead of listening to a queue (i.e.
|
<S,I> JmsMatsEndpoint<java.lang.Void,S,Z> |
terminator(java.lang.String endpointId,
java.lang.Class<S> stateClass,
java.lang.Class<I> incomingClass,
java.util.function.Consumer<? super MatsEndpoint.EndpointConfig<java.lang.Void,S>> endpointConfigLambda,
java.util.function.Consumer<? super MatsStage.StageConfig<java.lang.Void,S,I>> stageConfigLambda,
MatsEndpoint.ProcessTerminatorLambda<S,I> processor)
Variation of
#terminator(String, Class, Class, ProcessTerminatorLambda) that can be configured "on the
fly". |
<S,I> JmsMatsEndpoint<java.lang.Void,S,Z> |
terminator(java.lang.String endpointId,
java.lang.Class<S> stateClass,
java.lang.Class<I> incomingClass,
MatsEndpoint.ProcessTerminatorLambda<S,I> processor)
Sets up a
MatsEndpoint that contains a single stage that typically will be the reply-to endpointId for a
request initiation , or that can be used to directly send a
"fire-and-forget" style invocation to. |
java.lang.String |
toString() |
boolean |
waitForReceiving(int timeoutMillis)
Waits until all endpoints have fully entered the receive-loops, i.e.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
unwrapFully, unwrapTo
stopPhase0_SetRunFlagFalse, stopPhase1_CloseSessionIfInReceive, stopPhase2_GracefulWaitAfterRunflagFalse, stopPhase3_InterruptIfStillAlive, stopPhase4_GracefulWaitAfterInterrupt
createFlowId, getInvocationPoint, handleIncomingMessageMatsObject, handleIncomingState, id, id, ms3, produceAndSendMsgSysMessages, randomString, setConcurrencyWithLog, stageOrInit
public static final java.lang.String INTERCEPTOR_CLASS_MATS_LOGGING
public static final java.lang.String INTERCEPTOR_CLASS_MATS_METRICS
public static <Z> JmsMatsFactory<Z> createMatsFactory_JmsOnlyTransactions(java.lang.String appName, java.lang.String appVersion, JmsMatsJmsSessionHandler jmsMatsJmsSessionHandler, MatsSerializer<Z> matsSerializer)
public static <Z> JmsMatsFactory<Z> createMatsFactory_JmsAndJdbcTransactions(java.lang.String appName, java.lang.String appVersion, JmsMatsJmsSessionHandler jmsMatsJmsSessionHandler, javax.sql.DataSource dataSource, MatsSerializer<Z> matsSerializer)
public static <Z> JmsMatsFactory<Z> createMatsFactory(java.lang.String appName, java.lang.String appVersion, JmsMatsJmsSessionHandler jmsMatsJmsSessionHandler, JmsMatsTransactionManager jmsMatsTransactionManager, MatsSerializer<Z> matsSerializer)
public void setDefaultKeepTrace(MatsInitiator.KeepTrace defaultKeepTrace)
MatsInitiator.KeepTrace.COMPACT
. Not yet moved to FactoryConfig, because I want to evaluate.
Must be set before the MatsFactory is "published", memory wise.defaultKeepTrace
- the default KeepTrace for Mats flows - the default for this default is MatsInitiator.KeepTrace.COMPACT
.public JmsMatsJmsSessionHandler getJmsMatsJmsSessionHandler()
public JmsMatsTransactionManager getJmsMatsTransactionManager()
public MatsSerializer<Z> getMatsSerializer()
public void addInitiationInterceptor(MatsInitiateInterceptor initiateInterceptor)
addInitiationInterceptor
in interface MatsInterceptable
public java.util.List<MatsInitiateInterceptor> getInitiationInterceptors()
getInitiationInterceptors
in interface MatsInterceptable
public <T extends MatsInitiateInterceptor> java.util.Optional<T> getInitiationInterceptor(java.lang.Class<T> interceptorClass)
getInitiationInterceptor
in interface MatsInterceptable
public void removeInitiationInterceptor(MatsInitiateInterceptor initiateInterceptor)
removeInitiationInterceptor
in interface MatsInterceptable
public void addStageInterceptor(MatsStageInterceptor stageInterceptor)
addStageInterceptor
in interface MatsInterceptable
public java.util.List<MatsStageInterceptor> getStageInterceptors()
getStageInterceptors
in interface MatsInterceptable
public <T extends MatsStageInterceptor> java.util.Optional<T> getStageInterceptor(java.lang.Class<T> interceptorClass)
getStageInterceptor
in interface MatsInterceptable
public void removeStageInterceptor(MatsStageInterceptor stageInterceptor)
removeStageInterceptor
in interface MatsInterceptable
public MatsFactory.FactoryConfig getFactoryConfig()
getFactoryConfig
in interface MatsFactory
MatsFactory.FactoryConfig
on which to configure the factory, e.g. defaults for concurrency.public <R,S> JmsMatsEndpoint<R,S,Z> staged(java.lang.String endpointId, java.lang.Class<R> replyClass, java.lang.Class<S> stateClass)
MatsFactory
MatsEndpoint
on which you will add stages. The first stage is the one that will receive the
incoming (typically request) DTO, while any subsequent stage is invoked when the service that the previous stage
sent a request to, replies.
Unless the state object was sent along with the request
or
send
, the first stage will get a newly constructed empty state
instance, while the subsequent stages will get the state instance in the form it was left in the previous stage.staged
in interface MatsFactory
endpointId
- the identification of this MatsEndpoint
, which are the strings that should be provided to the
MatsInitiator.MatsInitiate.to(String)
or MatsInitiator.MatsInitiate.replyTo(String, Object)
methods for this
endpoint to get the message. Typical structure is "OrderService.placeOrder"
for public
endpoints, or "OrderService.private.validateOrder"
for private (app-internal) endpoints.replyClass
- the class that this endpoint shall return.stateClass
- the class of the State DTO that will be sent along the stages.MatsEndpoint
on which to add stages.public <R,S> JmsMatsEndpoint<R,S,Z> staged(java.lang.String endpointId, java.lang.Class<R> replyClass, java.lang.Class<S> stateClass, java.util.function.Consumer<? super MatsEndpoint.EndpointConfig<R,S>> endpointConfigLambda)
MatsFactory
MatsFactory.staged(String, Class, Class)
that can be configured "on the fly".staged
in interface MatsFactory
public <R,I> MatsEndpoint<R,java.lang.Void> single(java.lang.String endpointId, java.lang.Class<R> replyClass, java.lang.Class<I> incomingClass, MatsEndpoint.ProcessSingleLambda<R,I> processor)
MatsFactory
MatsEndpoint
that just contains one stage, useful for simple "request the full person data for
this/these personId(s)" scenarios. This sole stage is supplied directly, using a specialization of the processor
lambda which does not have state (as there is only one stage, there is no other stage to pass state to), but
which can return the reply by simply returning it on exit from the lambda.
Do note that this is just a convenience for the often-used scenario where for example a request will just be
looked up in the backing data store, and replied directly, using only one stage, not needing any multi-stage
processing.single
in interface MatsFactory
endpointId
- the identification of this MatsEndpoint
, which are the strings that should be provided to the
MatsInitiator.MatsInitiate.to(String)
or MatsInitiator.MatsInitiate.replyTo(String, Object)
methods for this
endpoint to get the message. Typical structure is "OrderService.placeOrder"
for public
endpoints, or "OrderService.private.validateOrder"
for private (app-internal) endpoints.replyClass
- the class that this endpoint shall return.incomingClass
- the class of the incoming (typically request) DTO.processor
- the stage
that will be invoked to process the incoming message.MatsEndpoint
, but you should not add any stages to it, as the sole stage is already added.public <R,I> JmsMatsEndpoint<R,java.lang.Void,Z> single(java.lang.String endpointId, java.lang.Class<R> replyClass, java.lang.Class<I> incomingClass, java.util.function.Consumer<? super MatsEndpoint.EndpointConfig<R,java.lang.Void>> endpointConfigLambda, java.util.function.Consumer<? super MatsStage.StageConfig<R,java.lang.Void,I>> stageConfigLambda, MatsEndpoint.ProcessSingleLambda<R,I> processor)
MatsFactory
#single(String, Class, Class, ProcessSingleLambda)
that can be configured "on the fly".single
in interface MatsFactory
public <S,I> JmsMatsEndpoint<java.lang.Void,S,Z> terminator(java.lang.String endpointId, java.lang.Class<S> stateClass, java.lang.Class<I> incomingClass, MatsEndpoint.ProcessTerminatorLambda<S,I> processor)
MatsFactory
MatsEndpoint
that contains a single stage that typically will be the reply-to endpointId for a
request initiation
, or that can be used to directly send a
"fire-and-forget" style invocation
to. The sole stage is supplied directly.
This type of endpoint cannot reply, as it has no-one to reply to (hence "terminator").
Do note that this is just a convenience for the often-used scenario where an initiation requests out to some
service, and then the reply needs to be handled - and with that the process is finished. That last endpoint which
handles the reply is what is referred to as a terminator, in that it has nowhere to reply to. Note that there is
nothing hindering you in setting the replyTo endpointId in a request initiation to point to a single-stage or
multi-stage endpoint - however, any replies from those endpoints will just go void.
It is possible to initiate
from within a terminator, and one
interesting scenario here is to do a publish
to a
subscriptionTerminator
. The idea
is then that you do the actual processing via a request, and upon the reply processing in the terminator, you
update the app database with the updated information (e.g. "order is processed"), and then you publish an "update
caches" message to all the nodes of the app, so that they all have the new state of the order in their caches
(or, in a push-based GUI logic, you might want to update all users' view of that order). Note that you (as in the
processing node) will also get that published message on your instance of the SubscriptionTerminator.
It is technically possible reply
from within a terminator - but it hard to
envision many wise usage scenarios for this, as the stack at a terminator would probably be empty.terminator
in interface MatsFactory
endpointId
- the identification of this MatsEndpoint
, which are the strings that should be provided to the
MatsInitiator.MatsInitiate.to(String)
or MatsInitiator.MatsInitiate.replyTo(String, Object)
methods for this
endpoint to get the message. Typical structure is "OrderService.placeOrder"
for public
endpoints (which then is of a "fire-and-forget" style, since a terminator is not meant to reply), or
"OrderService.terminator.validateOrder"
for private (app-internal) terminators that is
targeted by the replyTo(endpointId,..)
invocation of an
initiation.stateClass
- the class of the State DTO that will may be provided by the
request initiation
(or that was sent along with the
invocation
).incomingClass
- the class of the incoming (typically reply) DTO.processor
- the stage
that will be invoked to process the incoming message.MatsEndpoint
, but you should not add any stages to it, as the sole stage is already added.public <S,I> JmsMatsEndpoint<java.lang.Void,S,Z> terminator(java.lang.String endpointId, java.lang.Class<S> stateClass, java.lang.Class<I> incomingClass, java.util.function.Consumer<? super MatsEndpoint.EndpointConfig<java.lang.Void,S>> endpointConfigLambda, java.util.function.Consumer<? super MatsStage.StageConfig<java.lang.Void,S,I>> stageConfigLambda, MatsEndpoint.ProcessTerminatorLambda<S,I> processor)
MatsFactory
#terminator(String, Class, Class, ProcessTerminatorLambda)
that can be configured "on the
fly".terminator
in interface MatsFactory
public <S,I> JmsMatsEndpoint<java.lang.Void,S,Z> subscriptionTerminator(java.lang.String endpointId, java.lang.Class<S> stateClass, java.lang.Class<I> incomingClass, MatsEndpoint.ProcessTerminatorLambda<S,I> processor)
MatsFactory
MatsInitiator.MatsInitiate.publish(Object)
or MatsInitiator.MatsInitiate.replyToSubscription(String, Object)
methods.
Notice that the concurrency of a SubscriptionTerminator is always 1, as it makes no sense to have multiple
processors for a subscription - all of the processors would just get an identical copy of each message. If
you do need to handle massive amounts of messages, or your work handling is slow, you should instead of handling
the work in the processor itself, rather accept the message as fast as possible and send the work out to be
processed by some kind of thread pool. (The tool MatsFuturizer
does this for its Future-completion
handling).subscriptionTerminator
in interface MatsFactory
endpointId
- the identification of this MatsEndpoint
, which are the strings that should be provided to the
MatsInitiator.MatsInitiate.to(String)
or MatsInitiator.MatsInitiate.replyTo(String, Object)
methods for this
endpoint to get the message.stateClass
- the class of the State DTO that will may be provided by the
request initiation
(or that was sent along with the
invocation
).incomingClass
- the class of the incoming (typically reply) DTO.processor
- the stage
that will be invoked to process the incoming message.MatsEndpoint
, but you should not add any stages to it, as the sole stage is already added.public <S,I> JmsMatsEndpoint<java.lang.Void,S,Z> subscriptionTerminator(java.lang.String endpointId, java.lang.Class<S> stateClass, java.lang.Class<I> incomingClass, java.util.function.Consumer<? super MatsEndpoint.EndpointConfig<java.lang.Void,S>> endpointConfigLambda, java.util.function.Consumer<? super MatsStage.StageConfig<java.lang.Void,S,I>> stageConfigLambda, MatsEndpoint.ProcessTerminatorLambda<S,I> processor)
MatsFactory
#subscriptionTerminator(String, Class, Class, ProcessTerminatorLambda)
that can be
configured "on the fly", but notice that the concurrency of a SubscriptionTerminator is always 1.subscriptionTerminator
in interface MatsFactory
public MatsInitiator getDefaultInitiator()
MatsFactory
ProcessContext.initiate(..)
. The idea here is that you thus can
create methods that both can be used from the outside of a Mats Stage (thus resulting in an ordinary initiation),
but if the same method is invoked within a Mats Stage, the initiation will partake in the same transactional
demarcation as the rest of what happens within that Mats Stage. Note that you get a bit strange semantics wrt.
the exceptions that MatsInitiator.initiate(..)
and
MatsInitiator.initiateUnchecked(..)
raises: Outside of a
Mats Stage, they can throw in the given situations those exceptions describe. However, within a Mats Stage, they
will never throw those exceptions, since the actual initiation is not performed until the Mats Stage exits. But,
if you want to make such a dual mode method that can be employed both outside and within a Mats Stage, you should
thus code for the "Outside" mode, handling those Exceptions as you would in an ordinary initiation.
If you would really NOT want this - i.e. you for some reason want the initiation performed within the stage to
execute even though the Mats Stage fails - you may use MatsFactory.getOrCreateInitiator(String)
, and you can even
request the same underlying default initiator by just supplying that method with the argument "default". Please,
however, make sure you understand the quite heavy consequence of this: If the Mats Stage throws, the
retry-mechanism will kick in, running the Mats Stage one more time, and you will thus potentially send that
message many times - one time per retry - since such an initiation with a NON-default MatsInitiator is
specifically then not part of the Stage's transactional demarcation.
Just to ensure that this point comes across: The returned MatsInitiator is Thread Safe, and meant for reuse:
You are not supposed to create one instance of MatsInitiator
per message you need to send, and
then close it afterwards - rather either create one for the entire application, or e.g. for each component:
The MatsInitiator
can have underlying backend resources attached to it - which also means that it needs
to be closed
for a clean application shutdown (Note that all MatsInitiators are
closed when MatsFactory.stop()
is invoked).getDefaultInitiator
in interface MatsFactory
MatsInitiator
, whose name is 'default', on which messages can be
initiated
.MatsFactory.ContextLocal.getAttribute(Class, String...)
public MatsInitiator getOrCreateInitiator(java.lang.String name)
MatsFactory
MatsInitiator
could be that each initiator might have its own
connection to the underlying message broker. You also might want to name the initiators based on what part of the
application uses it; The name of the initiator shows up in monitors and tooling.
IMPORTANT NOTICE!! Please read the JavaDoc of MatsFactory.getDefaultInitiator()
for important information
wrt. transactional demarcation when employing a NON-default MatsInitiator within a Mats Stage.
Just to ensure that this point comes across: The returned MatsInitiator is Thread Safe, and meant for reuse:
You are not supposed to create one instance of MatsInitiator
per message you need to send, and
then close it afterwards - rather either create one for the entire application, or e.g. for each component:
The MatsInitiator
can have underlying backend resources attached to it - which also means that it needs
to be closed
for a clean application shutdown (Note that all MatsInitiators are
closed when MatsFactory.stop()
is invoked).getOrCreateInitiator
in interface MatsFactory
MatsInitiator
, on which messages can be initiated
.public io.mats3.impl.jms.JmsMatsInitiator<Z> getOrCreateInitiator_internal(java.lang.String name)
public java.util.List<MatsEndpoint<?,?>> getEndpoints()
getEndpoints
in interface MatsFactory
MatsEndpoint
s created on this MatsFactory
.public java.util.Optional<MatsEndpoint<?,?>> getEndpoint(java.lang.String endpointId)
getEndpoint
in interface MatsFactory
endpointId
- which MatsEndpoint
to return, if present.MatsEndpoint
if present, Optional.empty()
if not.public java.util.List<MatsInitiator> getInitiators()
getInitiators
in interface MatsFactory
MatsInitiator
s created on this MatsFactory
.public void start()
MatsFactory
MatsEndpoint.start()
on them.
Subsequently clears the MatsFactory.holdEndpointsUntilFactoryIsStarted()
-flag.start
in interface MatsConfig.StartStoppable
start
in interface MatsFactory
public void holdEndpointsUntilFactoryIsStarted()
MatsFactory
MatsEndpoint.finishSetup()
is invoked on them, but will wait till MatsFactory.start()
is invoked on the
factory. This feature should be employed in most setups where the MATS endpoints might use other services or
components whose order of creation and initialization are difficult to fully control, e.g. typically in an IoC
container like Spring. Set up the "internal machinery" of the system, including internal services, and only after
all this is running, then fire up the endpoints. If this is not done, the endpoints might start consuming
messages off of the MQ (there might already be messages waiting when the service boots), and thus invoke
services/components that are not yet fully started.
Note: To implement delayed start for a specific endpoint, simply hold off on invoking
MatsEndpoint.finishSetup()
until you are OK with it being started and hence starts consuming messages
(e.g. when the needed cache service is finished populated); This semantics works both when
holdEndpointsUntilFactoryIsStarted() has been invoked or not.holdEndpointsUntilFactoryIsStarted
in interface MatsFactory
MatsEndpoint.finishSetup()
,
MatsEndpoint.start()
public java.util.List<JmsMatsStartStoppable> getChildrenStartStoppable()
JmsMatsStartStoppable
getChildrenStartStoppable
in interface JmsMatsStartStoppable
public boolean waitForReceiving(int timeoutMillis)
MatsFactory
MatsEndpoint.waitForReceiving(int)
on all the endpoints started from this factory.
Note: If there are no Endpoints registered, this will immediately return true
!waitForReceiving
in interface JmsMatsStartStoppable
waitForReceiving
in interface MatsConfig.StartStoppable
waitForReceiving
in interface MatsFactory
timeoutMillis
- number of milliseconds before giving up the wait, returning false
. 0 is indefinite
wait, negative values are not allowed.true
if the entity started within the timeout, false
if it did not start.public boolean isHoldEndpointsUntilFactoryIsStarted()
public void close()
stop(30_000)
.close
in interface MatsFactory
public boolean stop(int gracefulShutdownMillis)
MatsFactory
MatsEndpoint.stop(int)
on all the endpoints, and
MatsInitiator.close()
on all initiators that has been created by this factory. They can be started again
individually, or all at once by invoking MatsFactory.start()
Should be invoked at application shutdown.stop
in interface JmsMatsStartStoppable
stop
in interface MatsConfig.StartStoppable
stop
in interface MatsFactory
gracefulShutdownMillis
- number of milliseconds to let the stage processors wait after having asked for them to shut down,
and interrupting them if they have not shut down yet.true
if all Endpoints (incl. e.g. threads) and resources (e.g. JMS Connections) closed
successfully.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String idThis()
idThis
in interface JmsMatsStatics
public java.lang.String toString()
toString
in class java.lang.Object