Package io.mats3

Interface MatsInitiator

All Superinterfaces:
AutoCloseable, Closeable

public interface MatsInitiator extends Closeable
Provides the means to get hold of a MatsInitiator.MatsInitiate instance for initiating Mats message flows: You fetch an instance implementing this interface using typically MatsFactory.getDefaultInitiator(), and then invoke initiate(InitiateLambda), where the lambda will provide you with the necessary MatsInitiator.MatsInitiate instance on which you have methods to construct and dispatch e.g. "send" and "request" Messages.

Notice: This class is Thread Safe - you are not supposed to make one instance per message initiation, but rather make one (or a few) for the entire application, and use it/them for all your initiation needs. The mentioned MatsFactory.getDefaultInitiator() is what you typically want to use, get the instance, and keep it to perform all your Mats initiations. For example, in a Spring-based service, you'd typically put it in the Spring context, and inject it where ever there is a need to perform Mats initiations.

Implementation Note: It shall be possible to use instances of MatsInitiator as keys in a HashMap, i.e. their equals and hashCode should remain stable throughout the life of the MatsFactory - and similar instances but with different MatsFactory are not equals. Depending on the implementation, instance equality may be sufficient.