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 TypeMethodDescriptionvoid
Add byte[] sideload to outgoing message.void
Add String sideload to outgoing message.boolean
byte[]
getData()
int
long
long
long
int
int
getFrom()
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.long
int
long
getTo()
<T> T
getTraceProperty
(String propertyName, Class<T> type) getWhat()
int
hashCode()
boolean
boolean
boolean
boolean
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.void
setSameStackHeightExtraState
(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.void
setTraceProperty
(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:
getTraceId
in interfaceMatsOutgoingMessage
-
getFlowId
- Specified by:
getFlowId
in interfaceMatsOutgoingMessage
-
isNonPersistent
public boolean isNonPersistent()- Specified by:
isNonPersistent
in interfaceMatsOutgoingMessage
-
getTimeToLive
public long getTimeToLive()- Specified by:
getTimeToLive
in interfaceMatsOutgoingMessage
-
isInteractive
public boolean isInteractive()- Specified by:
isInteractive
in interfaceMatsOutgoingMessage
-
isNoAudit
public boolean isNoAudit()- Specified by:
isNoAudit
in interfaceMatsOutgoingMessage
-
getInitiatingAppName
- Specified by:
getInitiatingAppName
in interfaceMatsOutgoingMessage
-
getInitiatingAppVersion
- Specified by:
getInitiatingAppVersion
in interfaceMatsOutgoingMessage
-
getInitiatorId
Description copied from interface:MatsOutgoingMessage
Note: 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:
getInitiatorId
in interfaceMatsOutgoingMessage
- Returns:
- the value supplied to
MatsInitiator.MatsInitiate.from(String)
at the time of the Mats flow initiation.
-
getMatsMessageId
- Specified by:
getMatsMessageId
in interfaceMatsOutgoingMessage
-
getMessageType
- Specified by:
getMessageType
in interfaceMatsOutgoingMessage
-
getDispatchType
- Specified by:
getDispatchType
in interfaceMatsOutgoingMessage
-
getTracePropertyKeys
- Specified by:
getTracePropertyKeys
in interfaceMatsOutgoingMessage
-
getTraceProperty
- Specified by:
getTraceProperty
in interfaceMatsOutgoingMessage
-
getBytesKeys
- Specified by:
getBytesKeys
in interfaceMatsOutgoingMessage
-
getBytes
- Specified by:
getBytes
in interfaceMatsOutgoingMessage
-
getStringKeys
- Specified by:
getStringKeys
in interfaceMatsOutgoingMessage
-
getString
- Specified by:
getString
in interfaceMatsOutgoingMessage
-
getFrom
Description copied from interface:MatsOutgoingMessage
Note: 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:
getFrom
in interfaceMatsOutgoingMessage
- Returns:
- which stage the message is from, or for initiations, the same value as
MatsOutgoingMessage.getInitiatorId()
.
-
getTo
- Specified by:
getTo
in interfaceMatsOutgoingMessage
-
isToSubscription
public boolean isToSubscription()- Specified by:
isToSubscription
in interfaceMatsOutgoingMessage
-
getReplyTo
- Specified by:
getReplyTo
in interfaceMatsOutgoingMessage
-
isReplyToSubscription
- Specified by:
isReplyToSubscription
in interfaceMatsOutgoingMessage
-
getSameStackHeightState
- Specified by:
getSameStackHeightState
in 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:
getData
in interfaceMatsOutgoingMessage
- Returns:
- the outgoing data (DTO)
-
getInitialTargetState
- Specified by:
getInitialTargetState
in 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.MatsEditableOutgoingMessage
Set trace property.- Specified by:
setTraceProperty
in interfaceMatsOutgoingMessage.MatsEditableOutgoingMessage
-
setSameStackHeightExtraState
Description copied from interface:MatsOutgoingMessage.MatsEditableOutgoingMessage
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. "extra state" in addition to the State class that the user has specified for the Endpoint. Only relevant forMatsOutgoingMessage.MessageType.REQUEST
,MatsOutgoingMessage.MessageType.NEXT
andMatsOutgoingMessage.MessageType.GOTO
- will throwIllegalStateException
otherwise. 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:
setSameStackHeightExtraState
in interfaceMatsOutgoingMessage.MatsEditableOutgoingMessage
-
addBytes
Description copied from interface:MatsOutgoingMessage.MatsEditableOutgoingMessage
Add byte[] sideload to outgoing message.- Specified by:
addBytes
in interfaceMatsOutgoingMessage.MatsEditableOutgoingMessage
-
addString
Description copied from interface:MatsOutgoingMessage.MatsEditableOutgoingMessage
Add String sideload to outgoing message.- Specified by:
addString
in interfaceMatsOutgoingMessage.MatsEditableOutgoingMessage
-
getSystemMessageId
- Specified by:
getSystemMessageId
in interfaceMatsOutgoingMessage.MatsSentOutgoingMessage
-
getEnvelopeProduceNanos
public long getEnvelopeProduceNanos()- Specified by:
getEnvelopeProduceNanos
in 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:
getEnvelopeSerializationNanos
in interfaceMatsOutgoingMessage.MatsSentOutgoingMessage
- Returns:
- time taken (in nanoseconds) to serialize the Mats envelope.
-
getEnvelopeSerializedSize
public int getEnvelopeSerializedSize()- Specified by:
getEnvelopeSerializedSize
in 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:
getEnvelopeCompressionNanos
in interfaceMatsOutgoingMessage.MatsSentOutgoingMessage
- Returns:
- time taken (in nanoseconds) to compress the envelope - will be
0
if no compression was applied, while it will return > 0 if compression was applied.
-
getEnvelopeWireSize
public int getEnvelopeWireSize()- Specified by:
getEnvelopeWireSize
in 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:
getMessageSystemProduceAndSendNanos
in 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:
getDataSerializedSize
in interfaceMatsOutgoingMessage.MatsSentOutgoingMessage
- Returns:
- the number of units (bytes or characters) that the outgoing data (DTO) serialized to.
-
getMessageSystemTotalWireSize
public int getMessageSystemTotalWireSize()- Specified by:
getMessageSystemTotalWireSize
in 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
-