Package io.mats3.impl.jms
Class JmsMatsMessage<Z>
java.lang.Object
io.mats3.impl.jms.JmsMatsMessage<Z>
- All Implemented Interfaces:
MatsOutgoingMessage,MatsOutgoingMessage.MatsEditableOutgoingMessage,MatsOutgoingMessage.MatsSentOutgoingMessage
public class JmsMatsMessage<Z>
extends Object
implements MatsOutgoingMessage.MatsEditableOutgoingMessage, MatsOutgoingMessage.MatsSentOutgoingMessage
Holds the entire contents of a "Mats Message" - so that it can be sent later.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.mats3.api.intercept.MatsOutgoingMessage
MatsOutgoingMessage.DispatchType, MatsOutgoingMessage.MatsEditableOutgoingMessage, MatsOutgoingMessage.MatsSentOutgoingMessage, MatsOutgoingMessage.MessageType -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd byte[] sideload to outgoing message.voidAdd String sideload to outgoing message.booleanbyte[]getData()intlonglonglongintintgetFrom()Note: For messages out of an initiator, this method andMatsOutgoingMessage.getInitiatorId()returns the same value, i.e.Note: For messages out of an initiator, this method andMatsOutgoingMessage.getFrom()returns the same value, i.e.longintlonggetTo()<T> TgetTraceProperty(String propertyName, Class<T> type) getWhat()inthashCode()booleanbooleanbooleanbooleanstatic <Z> JmsMatsMessage<Z>produceMessage(MatsOutgoingMessage.DispatchType dispatchType, long nanosAtStart_ProducingOutgoingMessage, MatsSerializer<Z> matsSerializer, MatsTrace<Z> outgoingMatsTrace, Object outgoingMessage, Object initialTargetState, Object sameStackHeightState, HashMap<String, Object> props, HashMap<String, byte[]> bytes, HashMap<String, String> strings) NOTE: The Maps are copied/cloned out, so invoker can do whatever he feels like with them afterwards.voidsetSameStackHeightExtraState(String key, Object object) An interceptor might need to add state to an outgoing message which will be present on incoming message of the next stage of a multi-stage endpoint - i.e.voidsetTraceProperty(String propertyName, Object object) Set trace property.
-
Method Details
-
produceMessage
public static <Z> JmsMatsMessage<Z> produceMessage(MatsOutgoingMessage.DispatchType dispatchType, long nanosAtStart_ProducingOutgoingMessage, MatsSerializer<Z> matsSerializer, MatsTrace<Z> outgoingMatsTrace, Object outgoingMessage, Object initialTargetState, Object sameStackHeightState, HashMap<String, Object> props, HashMap<String, byte[]> bytes, HashMap<String, String> strings) NOTE: The Maps are copied/cloned out, so invoker can do whatever he feels like with them afterwards. -
getWhat
-
getMatsTrace
-
getTraceId
- Specified by:
getTraceIdin interfaceMatsOutgoingMessage
-
getFlowId
- Specified by:
getFlowIdin interfaceMatsOutgoingMessage
-
isNonPersistent
public boolean isNonPersistent()- Specified by:
isNonPersistentin interfaceMatsOutgoingMessage
-
getTimeToLive
public long getTimeToLive()- Specified by:
getTimeToLivein interfaceMatsOutgoingMessage
-
isInteractive
public boolean isInteractive()- Specified by:
isInteractivein interfaceMatsOutgoingMessage
-
isNoAudit
public boolean isNoAudit()- Specified by:
isNoAuditin interfaceMatsOutgoingMessage
-
getInitiatingAppName
- Specified by:
getInitiatingAppNamein interfaceMatsOutgoingMessage
-
getInitiatingAppVersion
- Specified by:
getInitiatingAppVersionin interfaceMatsOutgoingMessage
-
getInitiatorId
Description copied from interface:MatsOutgoingMessageNote: For messages out of an initiator, this method andMatsOutgoingMessage.getFrom()returns the same value, i.e. it is "initiated from", and "from", the same source.- Specified by:
getInitiatorIdin interfaceMatsOutgoingMessage- Returns:
- the value supplied to
MatsInitiator.MatsInitiate.from(String)at the time of the Mats flow initiation.
-
getMatsMessageId
- Specified by:
getMatsMessageIdin interfaceMatsOutgoingMessage
-
getMessageType
- Specified by:
getMessageTypein interfaceMatsOutgoingMessage
-
getDispatchType
- Specified by:
getDispatchTypein interfaceMatsOutgoingMessage
-
getTracePropertyKeys
- Specified by:
getTracePropertyKeysin interfaceMatsOutgoingMessage
-
getTraceProperty
- Specified by:
getTracePropertyin interfaceMatsOutgoingMessage
-
getBytesKeys
- Specified by:
getBytesKeysin interfaceMatsOutgoingMessage
-
getBytes
- Specified by:
getBytesin interfaceMatsOutgoingMessage
-
getStringKeys
- Specified by:
getStringKeysin interfaceMatsOutgoingMessage
-
getString
- Specified by:
getStringin interfaceMatsOutgoingMessage
-
getFrom
Description copied from interface:MatsOutgoingMessageNote: For messages out of an initiator, this method andMatsOutgoingMessage.getInitiatorId()returns the same value, i.e. it is "initiated from", and "from", the same source.- Specified by:
getFromin interfaceMatsOutgoingMessage- Returns:
- which stage the message is from, or for initiations, the same value as
MatsOutgoingMessage.getInitiatorId().
-
getTo
- Specified by:
getToin interfaceMatsOutgoingMessage
-
isToSubscription
public boolean isToSubscription()- Specified by:
isToSubscriptionin interfaceMatsOutgoingMessage
-
getReplyTo
- Specified by:
getReplyToin interfaceMatsOutgoingMessage
-
isReplyToSubscription
- Specified by:
isReplyToSubscriptionin interfaceMatsOutgoingMessage
-
getSameStackHeightState
- Specified by:
getSameStackHeightStatein interfaceMatsOutgoingMessage- Returns:
- the "same stackheight" outgoing state; If this is a Request, it is the state that will be present upon
the subsequent Reply. If this is a Next, it is the state present on the nest stage. If it is a Goto, it
will be the "intialState" if set - and thus same as
MatsOutgoingMessage.getInitialTargetState().
-
getData
- Specified by:
getDatain interfaceMatsOutgoingMessage- Returns:
- the outgoing data (DTO)
-
getInitialTargetState
- Specified by:
getInitialTargetStatein interfaceMatsOutgoingMessage- Returns:
- for initiations and Goto, it is possible to send along an initial incoming target state - this returns that.
-
setTraceProperty
Description copied from interface:MatsOutgoingMessage.MatsEditableOutgoingMessageSet trace property.- Specified by:
setTracePropertyin interfaceMatsOutgoingMessage.MatsEditableOutgoingMessage
-
setSameStackHeightExtraState
Description copied from interface:MatsOutgoingMessage.MatsEditableOutgoingMessageAn interceptor might need to add state to an outgoing message which will be present on incoming message of the next stage of a multi-stage endpoint - i.e. "extra state" in addition to the State class that the user has specified for the Endpoint. Only relevant forMatsOutgoingMessage.MessageType.REQUEST,MatsOutgoingMessage.MessageType.NEXTandMatsOutgoingMessage.MessageType.GOTO- will throwIllegalStateExceptionotherwise. REQUEST: If extra-state is added to an outgoing REQUEST-message from ServiceA.stage1, it will be present again on the subsequent REPLY-message to ServiceA.stage2 (and any subsequent stages). NEXT: If extra-state is added to an outgoing NEXT-message from ServiceA.stage1, it will be present again on the subsequent incoming message to ServiceA.stage2 (and any subsequent stages). To add info to the receiving stage of a REQUEST, you may employMatsOutgoingMessage.MatsEditableOutgoingMessage.addBytes(String, byte[])andMatsOutgoingMessage.MatsEditableOutgoingMessage.addString(String, String). Given that such extra-state would need support from the receiving endpoint too to make much sense (i.e. an installed interceptor reading and understanding the incoming extra state, typically the same interceptor installed there as the one adding the state), it could just pick up the side load and transfer it over to the extra state if that was desired. Therefore, even though it could be possible to add extra-state to the targeted/receiving endpoint, I've decided against it so far. The extra-state is available on the stage interception atMatsStageInterceptor.StageCommonContext.getIncomingSameStackHeightExtraState(String, Class).- Specified by:
setSameStackHeightExtraStatein interfaceMatsOutgoingMessage.MatsEditableOutgoingMessage
-
addBytes
Description copied from interface:MatsOutgoingMessage.MatsEditableOutgoingMessageAdd byte[] sideload to outgoing message.- Specified by:
addBytesin interfaceMatsOutgoingMessage.MatsEditableOutgoingMessage
-
addString
Description copied from interface:MatsOutgoingMessage.MatsEditableOutgoingMessageAdd String sideload to outgoing message.- Specified by:
addStringin interfaceMatsOutgoingMessage.MatsEditableOutgoingMessage
-
getSystemMessageId
- Specified by:
getSystemMessageIdin interfaceMatsOutgoingMessage.MatsSentOutgoingMessage
-
getEnvelopeProduceNanos
public long getEnvelopeProduceNanos()- Specified by:
getEnvelopeProduceNanosin interfaceMatsOutgoingMessage.MatsSentOutgoingMessage- Returns:
- time taken (in nanoseconds) to create the Mats envelope, including serialization of all relevant
constituents: DTO, STO and any Trace Properties. Note that this will be a slice of the user lambda
timing (
getUserLambdaNanos()for both init and stage), as it is done at the time of e.g. invokingprocessContext.request()inside the user lambda.
-
getEnvelopeSerializationNanos
public long getEnvelopeSerializationNanos()- Specified by:
getEnvelopeSerializationNanosin interfaceMatsOutgoingMessage.MatsSentOutgoingMessage- Returns:
- time taken (in nanoseconds) to serialize the Mats envelope.
-
getEnvelopeSerializedSize
public int getEnvelopeSerializedSize()- Specified by:
getEnvelopeSerializedSizein interfaceMatsOutgoingMessage.MatsSentOutgoingMessage- Returns:
- size (in bytes) of the serialized envelope - before compression. Do read the JavaDoc of
MatsOutgoingMessage.MatsSentOutgoingMessage.getEnvelopeWireSize()too, as the same applies here: This size only refers to the Mats envelope, not the messaging system's final message size.
-
getEnvelopeCompressionNanos
public long getEnvelopeCompressionNanos()- Specified by:
getEnvelopeCompressionNanosin interfaceMatsOutgoingMessage.MatsSentOutgoingMessage- Returns:
- time taken (in nanoseconds) to compress the envelope - will be
0if no compression was applied, while it will return > 0 if compression was applied.
-
getEnvelopeWireSize
public int getEnvelopeWireSize()- Specified by:
getEnvelopeWireSizein interfaceMatsOutgoingMessage.MatsSentOutgoingMessage- Returns:
- size (in bytes) of the envelope after compression, which will be put inside the messaging system's
message envelope. If compression was not applied, returns the same value as
MatsOutgoingMessage.MatsSentOutgoingMessage.getEnvelopeSerializedSize(). Note that the returned size is only the (compressed) Mats envelope, and does not include the size of the messaging system's message/envelope and any meta-data that Mats adds to this. This means that the message size on the wire will be larger.
-
getMessageSystemProduceAndSendNanos
public long getMessageSystemProduceAndSendNanos()- Specified by:
getMessageSystemProduceAndSendNanosin interfaceMatsOutgoingMessage.MatsSentOutgoingMessage- Returns:
- time taken (in nanoseconds) to produce, and then send (transfer) the message to the message broker.
-
getDataSerializedSize
public int getDataSerializedSize()- Specified by:
getDataSerializedSizein interfaceMatsOutgoingMessage.MatsSentOutgoingMessage- Returns:
- the number of units (bytes or characters) that the outgoing data (DTO) serialized to.
-
getMessageSystemTotalWireSize
public int getMessageSystemTotalWireSize()- Specified by:
getMessageSystemTotalWireSizein interfaceMatsOutgoingMessage.MatsSentOutgoingMessage- Returns:
- the number of bytes sent on the wire (best approximation), as far as Mats knows. Any overhead from the message system is unknown. Includes the envelope (which includes the TraceProperties), as well as the sideloads (bytes and strings). Implementation might add some more size for metadata. Notice that the strings are just "length()'ed", so any "exotic" characters are still just counted as 1 byte.
-
hashCode
public int hashCode() -
equals
-