Package com.mayam.wf.mq
Class MqMessage
java.lang.Object
com.mayam.wf.mq.MqMessage
A message to be sent or listened for via
Mq
.- Author:
- Markus MÃ¥rtensson
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Describes a change in a task or asset by providing before and after representations. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets a message property value.<T> T
Gets a message property value, converting it to the requested class usingValueNormalizer
.byte[]
Returns the message text content.Returns an combined before/afterAttributeMap
derived from the message text content.Gets all message properties.Returns anSegmentList
derived from the message text content.Returns anAttributeMap
derived from the message text content.Returns anMqMessage.AttributeMapPair
derived from the message text content.getType()
Returns the message type.boolean
void
injectHelpers
(Mq mq, ValueNormalizer normalizer, com.mayam.wf.attributes.server.AttributeMapMapper mapper) boolean
isLarge()
Returns whether the message is too large to have its contents passed directly through the MQ.Retrieves the names of properties defined within the messsage.void
send
(MqDestination destination) CallsMq.send(MqDestination, MqMessage)
to send this message to a queue or topic.void
sendVolatile
(MqDestination destination) CallsMq.sendVolatile(MqDestination, MqMessage)
to send this message to a queue or topic.Sets a message property, converting the provided value to a string usingValueNormalizer
.Sets a message property.setByteContent
(byte[] byteContent) Sets the message byte content.setContent
(String content) Sets the message text content.setLarge
(boolean large) Sets whether the message is too large to have its contents passed directly through the MQ.setProperties
(Map<String, String> properties) Sets all message properties, replacing any already set.setType
(MqContentType type) Sets the message type.toString()
-
Field Details
-
LARGE_THRESHOLD
public static final int LARGE_THRESHOLDMessages with a content length passing the threshold are considered large and will get special treatment. A replay store will be created and a matchingPROP_MESSAGE_URL
property added to the message passed to the MQ.- See Also:
-
PROP_MESSAGE_URL
- See Also:
-
PROP_ORIGIN_DATE
- See Also:
-
PROP_ORIGIN_DESTINATION
- See Also:
-
PROP_MQ_MESSAGE_TYPE
- See Also:
-
PROP_MESSAGE_ROUTING_KEY
- See Also:
-
PROP_MESSAGE_EXCHANGE_NAME
- See Also:
-
-
Constructor Details
-
MqMessage
public MqMessage()
-
-
Method Details
-
propertyNames
Retrieves the names of properties defined within the messsage. -
get
Gets a message property value.- Parameters:
name
- property name.- Returns:
- value.
-
get
Gets a message property value, converting it to the requested class usingValueNormalizer
.- Parameters:
name
- property name.valueClass
- expected value class.- Returns:
- converted value.
- Throws:
IllegalArgumentException
- if the property value can not be converted into valueClass.
-
set
Sets a message property.- Parameters:
name
- property name.value
- property value.- Returns:
- the MqMessage itself, for fluid chaining purposes.
-
set
Sets a message property, converting the provided value to a string usingValueNormalizer
.- Parameters:
name
- property name.value
- property value.- Returns:
- the MqMessage itself, for fluid chaining purposes.
- Throws:
IllegalArgumentException
- if the value can not be converted into a string.
-
setProperties
Sets all message properties, replacing any already set.- Parameters:
properties
- property map.- Returns:
- the MqMessage itself, for fluid chaining purposes.
-
getProperties
Gets all message properties. -
getContent
Returns the message text content.- Throws:
MqException
- if the content of a large message could not be retrieved via HTTP.
-
getSubject
Returns anAttributeMap
derived from the message text content. -
getFullSubject
Returns an combined before/afterAttributeMap
derived from the message text content. -
getSegmentList
Returns anSegmentList
derived from the message text content. -
getSubjectPair
Returns anMqMessage.AttributeMapPair
derived from the message text content. -
setContent
Sets the message text content.- Returns:
- the MqMessage itself, for fluid chaining purposes.
-
setByteContent
Sets the message byte content.- Parameters:
byteContent
-- Returns:
-
getByteContent
public byte[] getByteContent() -
hasByteContent
public boolean hasByteContent() -
getType
Returns the message type. -
setType
Sets the message type.- Returns:
- the MqMessage itself, for fluid chaining purposes.
-
isLarge
public boolean isLarge()Returns whether the message is too large to have its contents passed directly through the MQ. -
setLarge
Sets whether the message is too large to have its contents passed directly through the MQ.- Returns:
- the MqMessage itself, for fluid chaining purposes.
-
send
CallsMq.send(MqDestination, MqMessage)
to send this message to a queue or topic.- Parameters:
destination
- destination.- Throws:
MqException
- on failure to send.
-
sendVolatile
CallsMq.sendVolatile(MqDestination, MqMessage)
to send this message to a queue or topic.- Parameters:
destination
- destination.
-
toString