Class AmqpJmsMessageFacade
java.lang.Object
org.apache.qpid.jms.provider.amqp.message.AmqpJmsMessageFacade
- All Implemented Interfaces:
JmsMessageFacade,TraceableMessage
- Direct Known Subclasses:
AmqpJmsBytesMessageFacade,AmqpJmsMapMessageFacade,AmqpJmsObjectMessageFacade,AmqpJmsStreamMessageFacade,AmqpJmsTextMessageFacade
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidClears the contents of this Message.voidClears any Message properties that exist for this Message instance.copy()Create a new instance and perform a deep copy of this object's contents.protected voidcopyInto(AmqpJmsMessageFacade target) io.netty.buffer.ByteBufEncodes the protocol level Message instance for transmission.voidfilterTracingAnnotations(BiConsumer<String, Object> filter) Allows the tracing layer to filter out tracing related details from the full set of message annotations that a message might be carrying.longgetApplicationPropertyNames(Set<String> propertyNames) org.apache.qpid.proton.amqp.SymbolThe annotation value for the JMS Message content type.Returns the correlation ID set on this message if one exists, null otherwise.byte[]Gets the set correlation ID of the message in raw bytes form.intReturns the current delivery count of the Message as set in the underlying message instance.longReturns the set delivery time for this message.Gets the Destination value that was assigned to this message at the time it was sent.longReturns the set expiration time for this message.Gets the Group ID that this message is assigned to.intGets the assigned group sequence of this message.byteReturns the message ID set on this message if one exists, null otherwise.intReturns the assigned priority value of this message in JMS ranged scoping.getProperty(String key) Returns the property stored in the message accessed via the given key/Returns a set of all the property names that have been set in this message.Returns the underlying providers message ID object for this message if one exists, null otherwise.intReturns the current redelivery count of the Message as set in the underlying message instance.Gets the Destination where replies for this Message are to be sent to.longGets the time stamp assigned to the message when it was sent.Gets some trace specific message annotation that was previously applied to the given message either locally or by a remote peer.getTracingContext(String key) Gets some trace related context from the message for use by the tracing implementation.getType()Returns the JMSType value as defined by the provider or set by the sending client.Returns the ID of the user that sent this message if available.byte[]Gets the set user ID of the message in raw bytes form.booleanbooleanhasBody()Returns true if the underlying message has a body, false if the body is empty.voidinitialize(AmqpConnection connection) Initialize the state of this message for send.voidinitialize(AmqpConsumer consumer) Initialize the state of this message for receive.protected voidUsed to indicate that a Message object should empty the body element and make any other internal updates to reflect the message now has no body value.booleanReturns whether the delivery time is being transmitted, i.e.booleanbooleanUsed to quickly check if a message has been redelivered.voidCalled before a message is dispatched to its intended consumer to allow for any necessary processing of message data such as setting read-only state etc.voidonSend(long producerTtl) Called before a message is sent to allow a Message instance to move the contents from a logical data structure to a binary form for transmission, or other processing such as setting proper message headers etc.booleanpropertyExists(String key) Remove some trace specific message annotation that was previously applied to the given message either locally or by a remote peer.Removes some trace related context from the message.voidSets a value which will be used to override any ttl value that may otherwise be set based on the expiration value when sending the underlying AMQP message.voidsetApplicationProperty(String key, Object value) voidsetContentType(org.apache.qpid.proton.amqp.Symbol value) voidsetCorrelationId(String correlationId) Sets the correlation ID for this message.voidsetCorrelationIdBytes(byte[] correlationId) Sets the correlation ID of the message in raw byte form.voidsetDeliveryCount(int deliveryCount) Sets the delivery count on the message.voidsetDeliveryTime(long deliveryTime, boolean transmit) Sets an desired delivery time on this message.voidsetDestination(JmsDestination destination) Sets the Destination that this message is being sent to.voidsetExpiration(long expiration) Sets an expiration time on this message.voidsetGroupId(String groupId) Sets the Group ID to use for this message.voidsetGroupSequence(int groupSequence) Sets the group sequence value for this message.voidsetMessageId(String messageId) Sets the message ID for this message.voidsetPersistent(boolean value) Sets the persistent flag on this message.voidsetPriority(int priority) Sets the message priority for this message using a JMS priority scoped value.voidsetProperty(String key, Object value) Sets the message property value using the supplied key to identify the value that should be set or updated.voidsetProviderMessageIdObject(Object messageId) Sets the underlying providers message ID object for this message, or clears it if the provided value is null.voidsetRedelivered(boolean redelivered) Used to set the redelivered state of a message.voidsetRedeliveryCount(int redeliveryCount) Used to update the message redelivery after a local redelivery of the Message has been performed.voidsetReplyTo(JmsDestination replyTo) Sets the Destination where replies to this Message are to be sent.voidsetReplyToGroupId(String replyToGroupId) voidsetTimestamp(long timestamp) Sets the time stamp value of this message.setTracingAnnotation(String key, Object value) Sets some trace specific message annotation that was previously applied to the given message either locally or by a remote peer.setTracingContext(String key, Object value) Sets some trace related context from the message for use by the tracing implementation.voidSets the String value used to define the Message JMSType by the client.voidSets the User ID for the connection that is being used to send this message.voidsetUserIdBytes(byte[] userId) Sets the user ID of the message in raw byte form.
-
Field Details
-
connection
-
-
Constructor Details
-
AmqpJmsMessageFacade
public AmqpJmsMessageFacade()
-
-
Method Details
-
initialize
Initialize the state of this message for send.- Parameters:
connection- The connection that this message is linked to.
-
initialize
Initialize the state of this message for receive.- Parameters:
consumer- The consumer that this message was read from.
-
initializeEmptyBody
protected void initializeEmptyBody()Used to indicate that a Message object should empty the body element and make any other internal updates to reflect the message now has no body value. -
getJmsMsgType
public byte getJmsMsgType()- Returns:
- the appropriate byte value that indicates the type of message this is.
-
getContentType
public org.apache.qpid.proton.amqp.Symbol getContentType()The annotation value for the JMS Message content type. For a generic JMS message this value is omitted so we return null here, subclasses should override this to return the correct content type value for their payload.- Returns:
- a Symbol value indicating the message content type.
-
setContentType
public void setContentType(org.apache.qpid.proton.amqp.Symbol value) -
propertyExists
- Specified by:
propertyExistsin interfaceJmsMessageFacade- Parameters:
key- The property name that is being searched for.- Returns:
- true if the given property exists within the message.
- Throws:
jakarta.jms.JMSException- if an error occurs while accessing the Message properties.
-
applicationPropertyExists
- Throws:
jakarta.jms.JMSException
-
getPropertyNames
Returns a set of all the property names that have been set in this message. The Set returned may be manipulated by the receiver without impacting the facade, and an empty set will be returned if there are no matching properties.- Specified by:
getPropertyNamesin interfaceJmsMessageFacade- Returns:
- a set of property names in the message or an empty set if none are set.
-
getApplicationPropertyNames
-
getProperty
Description copied from interface:JmsMessageFacadeReturns the property stored in the message accessed via the given key/- Specified by:
getPropertyin interfaceJmsMessageFacade- Parameters:
key- the key used to access the given property.- Returns:
- the object that is stored under the given key or null if none found.
- Throws:
jakarta.jms.JMSException- if an error occurs while accessing the Message properties.
-
getApplicationProperty
- Throws:
jakarta.jms.JMSException
-
setProperty
Description copied from interface:JmsMessageFacadeSets the message property value using the supplied key to identify the value that should be set or updated.- Specified by:
setPropertyin interfaceJmsMessageFacade- Parameters:
key- the key that identifies the message property.value- the value that is to be stored in the message.- Throws:
jakarta.jms.JMSException- if an error occurs while accessing the Message properties.
-
setApplicationProperty
- Throws:
jakarta.jms.JMSException
-
onSend
public void onSend(long producerTtl) throws jakarta.jms.JMSException Description copied from interface:JmsMessageFacadeCalled before a message is sent to allow a Message instance to move the contents from a logical data structure to a binary form for transmission, or other processing such as setting proper message headers etc. The method allows for passing through producer configuration details not explicitly mapped into the JMS Message allowing the facade to create the most correct and compact message on the wire.- Specified by:
onSendin interfaceJmsMessageFacade- Parameters:
producerTtl- the time to live value configured on the producer when sent.- Throws:
jakarta.jms.JMSException- if an error occurs while preparing the message for send.
-
onDispatch
public void onDispatch() throws jakarta.jms.JMSExceptionDescription copied from interface:JmsMessageFacadeCalled before a message is dispatched to its intended consumer to allow for any necessary processing of message data such as setting read-only state etc.- Specified by:
onDispatchin interfaceJmsMessageFacade- Throws:
jakarta.jms.JMSException- if an error occurs while preparing the message for dispatch.
-
clearBody
public void clearBody()Description copied from interface:JmsMessageFacadeClears the contents of this Message.- Specified by:
clearBodyin interfaceJmsMessageFacade
-
clearProperties
public void clearProperties() throws jakarta.jms.JMSExceptionDescription copied from interface:JmsMessageFacadeClears any Message properties that exist for this Message instance.- Specified by:
clearPropertiesin interfaceJmsMessageFacade- Throws:
jakarta.jms.JMSException- if an error occurs while accessing the message properties.
-
copy
Description copied from interface:JmsMessageFacadeCreate a new instance and perform a deep copy of this object's contents.- Specified by:
copyin interfaceJmsMessageFacade- Returns:
- a copy of this JmsMessageFacade instance.
- Throws:
jakarta.jms.JMSException- if an error occurs while copying the message.
-
copyInto
-
getMessageId
Description copied from interface:JmsMessageFacadeReturns the message ID set on this message if one exists, null otherwise. The returned value will include the JMS mandated 'ID:' prefix.- Specified by:
getMessageIdin interfaceJmsMessageFacade- Returns:
- the set message ID or null if not set.
-
getProviderMessageIdObject
Description copied from interface:JmsMessageFacadeReturns the underlying providers message ID object for this message if one exists, null otherwise. In the case the returned value is a String, it is not defined whether the JMS mandated 'ID:' prefix will be present.- Specified by:
getProviderMessageIdObjectin interfaceJmsMessageFacade- Returns:
- the set provider message ID or null if not set.
-
setProviderMessageIdObject
Description copied from interface:JmsMessageFacadeSets the underlying providers message ID object for this message, or clears it if the provided value is null.- Specified by:
setProviderMessageIdObjectin interfaceJmsMessageFacade- Parameters:
messageId- The message ID to set on this message, or null to clear.
-
setMessageId
Description copied from interface:JmsMessageFacadeSets the message ID for this message.- Specified by:
setMessageIdin interfaceJmsMessageFacade- Parameters:
messageId- The message ID to set on this message, or null to clear.- Throws:
IdConversionException
-
getTimestamp
public long getTimestamp()Description copied from interface:JmsMessageFacadeGets the time stamp assigned to the message when it was sent.- Specified by:
getTimestampin interfaceJmsMessageFacade- Returns:
- the message time stamp value.
-
setTimestamp
public void setTimestamp(long timestamp) Description copied from interface:JmsMessageFacadeSets the time stamp value of this message.- Specified by:
setTimestampin interfaceJmsMessageFacade- Parameters:
timestamp- the time that the message was sent by the provider.
-
getCorrelationId
Description copied from interface:JmsMessageFacadeReturns the correlation ID set on this message if one exists, null otherwise. The returned value will include the JMS mandated 'ID:' prefix if the value represents a JMSMessageID rather than an application-specific string.- Specified by:
getCorrelationIdin interfaceJmsMessageFacade- Returns:
- the set correlation ID or null if not set.
-
setCorrelationId
Description copied from interface:JmsMessageFacadeSets the correlation ID for this message.- Specified by:
setCorrelationIdin interfaceJmsMessageFacade- Parameters:
correlationId- The correlation ID to set on this message, or null to clear.- Throws:
IdConversionException
-
getCorrelationIdBytes
public byte[] getCorrelationIdBytes() throws jakarta.jms.JMSExceptionDescription copied from interface:JmsMessageFacadeGets the set correlation ID of the message in raw bytes form. If no ID was set then this method may return null or an empty byte array.- Specified by:
getCorrelationIdBytesin interfaceJmsMessageFacade- Returns:
- a byte array containing the correlation ID value in raw form.
- Throws:
jakarta.jms.JMSException- if an error occurs while accessing the property.
-
setCorrelationIdBytes
public void setCorrelationIdBytes(byte[] correlationId) Description copied from interface:JmsMessageFacadeSets the correlation ID of the message in raw byte form. Setting the value as null or an empty byte array will clear any previously set value. If the underlying protocol cannot convert or map the given byte value to it's own internal representation it should throw a JMSException indicating the error.- Specified by:
setCorrelationIdBytesin interfaceJmsMessageFacade- Parameters:
correlationId- the byte array to use to set the message correlation ID.
-
isPersistent
public boolean isPersistent()- Specified by:
isPersistentin interfaceJmsMessageFacade- Returns:
- true if this message is tagged as being persistent.
-
setPersistent
public void setPersistent(boolean value) Description copied from interface:JmsMessageFacadeSets the persistent flag on this message.- Specified by:
setPersistentin interfaceJmsMessageFacade- Parameters:
value- true if the message is to be marked as persistent.
-
getDeliveryCount
public int getDeliveryCount()Description copied from interface:JmsMessageFacadeReturns the current delivery count of the Message as set in the underlying message instance.- Specified by:
getDeliveryCountin interfaceJmsMessageFacade- Returns:
- the current delivery count.
-
setDeliveryCount
public void setDeliveryCount(int deliveryCount) Description copied from interface:JmsMessageFacadeSets the delivery count on the message.- Specified by:
setDeliveryCountin interfaceJmsMessageFacade- Parameters:
deliveryCount- the new delivery count to assign the Message.
-
getRedeliveryCount
public int getRedeliveryCount()Description copied from interface:JmsMessageFacadeReturns the current redelivery count of the Message as set in the underlying message instance.- Specified by:
getRedeliveryCountin interfaceJmsMessageFacade- Returns:
- the current redelivery count.
-
setRedeliveryCount
public void setRedeliveryCount(int redeliveryCount) Description copied from interface:JmsMessageFacadeUsed to update the message redelivery after a local redelivery of the Message has been performed.- Specified by:
setRedeliveryCountin interfaceJmsMessageFacade- Parameters:
redeliveryCount- the new redelivery count to assign the Message.
-
isRedelivered
public boolean isRedelivered()Description copied from interface:JmsMessageFacadeUsed to quickly check if a message has been redelivered.- Specified by:
isRedeliveredin interfaceJmsMessageFacade- Returns:
- true if the message was redelivered, false otherwise.
-
setRedelivered
public void setRedelivered(boolean redelivered) Description copied from interface:JmsMessageFacadeUsed to set the redelivered state of a message. This can serve to clear the redelivery counter or set its initial value to one.- Specified by:
setRedeliveredin interfaceJmsMessageFacade- Parameters:
redelivered- true if the message is to be marked as redelivered, false otherwise.
-
getType
Description copied from interface:JmsMessageFacadeReturns the JMSType value as defined by the provider or set by the sending client.- Specified by:
getTypein interfaceJmsMessageFacade- Returns:
- a String value that defines the message JMSType.
-
setType
Description copied from interface:JmsMessageFacadeSets the String value used to define the Message JMSType by the client.- Specified by:
setTypein interfaceJmsMessageFacade- Parameters:
type- the JMSType value the client assigns to this message.
-
getPriority
public int getPriority()Description copied from interface:JmsMessageFacadeReturns the assigned priority value of this message in JMS ranged scoping. If the provider does not define a message priority value in its message objects or the value is not set in the message this method should return the JMS default value of 4.- Specified by:
getPriorityin interfaceJmsMessageFacade- Returns:
- the priority value assigned to this message.
-
setPriority
public void setPriority(int priority) Description copied from interface:JmsMessageFacadeSets the message priority for this message using a JMS priority scoped value.- Specified by:
setPriorityin interfaceJmsMessageFacade- Parameters:
priority- the new priority value to set on this message.
-
getExpiration
public long getExpiration()Description copied from interface:JmsMessageFacadeReturns the set expiration time for this message. The value should be returned as an absolute time given in GMT time.- Specified by:
getExpirationin interfaceJmsMessageFacade- Returns:
- the time that this message expires or zero if it never expires.
-
setExpiration
public void setExpiration(long expiration) Description copied from interface:JmsMessageFacadeSets an expiration time on this message. The expiration time will be given as an absolute time in GMT time.- Specified by:
setExpirationin interfaceJmsMessageFacade- Parameters:
expiration- the time that this message should be considered as expired.
-
getDeliveryTime
public long getDeliveryTime()Description copied from interface:JmsMessageFacadeReturns the set delivery time for this message. The value should be returned as an absolute time given in GMT time.- Specified by:
getDeliveryTimein interfaceJmsMessageFacade- Returns:
- the earliest time that the message should be made available for delivery.
-
setDeliveryTime
public void setDeliveryTime(long deliveryTime, boolean transmit) Description copied from interface:JmsMessageFacadeSets an desired delivery time on this message. The delivery time will be given as an absolute time in GMT time.- Specified by:
setDeliveryTimein interfaceJmsMessageFacade- Parameters:
deliveryTime- the earliest time that the message should be made available for delivery.transmit- whether to transmit an annotation containing the value (if non-zero)
-
isDeliveryTimeTransmitted
public boolean isDeliveryTimeTransmitted()Description copied from interface:JmsMessageFacadeReturns whether the delivery time is being transmitted, i.e. incorporates an actual delivery delay.- Specified by:
isDeliveryTimeTransmittedin interfaceJmsMessageFacade- Returns:
- true if delivery time is being transmitted as an annotation
-
setAmqpTimeToLiveOverride
Sets a value which will be used to override any ttl value that may otherwise be set based on the expiration value when sending the underlying AMQP message. A value of 0 means to clear the ttl field rather than set it to anything.- Parameters:
ttl- the value to use, in range 0 <= x <= 2^32 - 1- Throws:
jakarta.jms.MessageFormatException- if the TTL value is not in the allowed range.
-
hasAmqpTimeToLiveOverride
public boolean hasAmqpTimeToLiveOverride() -
getAmqpTimeToLiveOverride
public long getAmqpTimeToLiveOverride() -
getDestination
Description copied from interface:JmsMessageFacadeGets the Destination value that was assigned to this message at the time it was sent.- Specified by:
getDestinationin interfaceJmsMessageFacade- Returns:
- the destination to which this message was originally sent.
-
setDestination
Description copied from interface:JmsMessageFacadeSets the Destination that this message is being sent to.- Specified by:
setDestinationin interfaceJmsMessageFacade- Parameters:
destination- the destination that this message is being sent to.
-
getReplyTo
Description copied from interface:JmsMessageFacadeGets the Destination where replies for this Message are to be sent to.- Specified by:
getReplyToin interfaceJmsMessageFacade- Returns:
- the reply to destination for this message or null if none set.
-
setReplyTo
Description copied from interface:JmsMessageFacadeSets the Destination where replies to this Message are to be sent.- Specified by:
setReplyToin interfaceJmsMessageFacade- Parameters:
replyTo- the Destination where replies should be sent, or null to clear.
-
setReplyToGroupId
-
getReplyToGroupId
-
getUserId
Description copied from interface:JmsMessageFacadeReturns the ID of the user that sent this message if available.- Specified by:
getUserIdin interfaceJmsMessageFacade- Returns:
- the user ID that was in use when this message was sent or null if not set.
-
setUserId
Description copied from interface:JmsMessageFacadeSets the User ID for the connection that is being used to send this message.- Specified by:
setUserIdin interfaceJmsMessageFacade- Parameters:
userId- the user ID that sent this message or null to clear.
-
getUserIdBytes
public byte[] getUserIdBytes()Description copied from interface:JmsMessageFacadeGets the set user ID of the message in raw bytes form. If no ID was set then this method may return null or an empty byte array.- Specified by:
getUserIdBytesin interfaceJmsMessageFacade- Returns:
- a byte array containing the user ID value in raw form.
-
setUserIdBytes
public void setUserIdBytes(byte[] userId) Description copied from interface:JmsMessageFacadeSets the user ID of the message in raw byte form. Setting the value as null or an empty byte array will clear any previously set value. If the underlying protocol cannot convert or map the given byte value to it's own internal representation it should throw a JMSException indicating the error.- Specified by:
setUserIdBytesin interfaceJmsMessageFacade- Parameters:
userId- the byte array to use to set the message user ID.
-
getGroupId
Description copied from interface:JmsMessageFacadeGets the Group ID that this message is assigned to.- Specified by:
getGroupIdin interfaceJmsMessageFacade- Returns:
- the Group ID this message was sent in.
-
setGroupId
Description copied from interface:JmsMessageFacadeSets the Group ID to use for this message.- Specified by:
setGroupIdin interfaceJmsMessageFacade- Parameters:
groupId- the Group ID that this message is assigned to.
-
getGroupSequence
public int getGroupSequence()Description copied from interface:JmsMessageFacadeGets the assigned group sequence of this message.- Specified by:
getGroupSequencein interfaceJmsMessageFacade- Returns:
- the assigned group sequence of this message.
-
setGroupSequence
public void setGroupSequence(int groupSequence) Description copied from interface:JmsMessageFacadeSets the group sequence value for this message.- Specified by:
setGroupSequencein interfaceJmsMessageFacade- Parameters:
groupSequence- the group sequence value to assign this message.
-
hasBody
public boolean hasBody()Description copied from interface:JmsMessageFacadeReturns true if the underlying message has a body, false if the body is empty.- Specified by:
hasBodyin interfaceJmsMessageFacade- Returns:
- true if the underlying message has a body, false if the body is empty.
-
asJmsMessage
-
encodeMessage
public io.netty.buffer.ByteBuf encodeMessage()Description copied from interface:JmsMessageFacadeEncodes the protocol level Message instance for transmission.- Specified by:
encodeMessagein interfaceJmsMessageFacade- Returns:
- an Object that represents the encoded form of the message for the target provider.
-
getTracingContext
Description copied from interface:TraceableMessageGets some trace related context from the message for use by the tracing implementation.Allows the Tracing implementation to store context data into the message without the message needing to know what the types or structure of that data is.
- Specified by:
getTracingContextin interfaceTraceableMessage- Parameters:
key- The name of the context element to be looked up.- Returns:
- the stored tracing context element or null if not present.
-
setTracingContext
Description copied from interface:TraceableMessageSets some trace related context from the message for use by the tracing implementation.Allows the Tracing implementation to store context data into the message without the message needing to know what the types or structure of that data is.
- Specified by:
setTracingContextin interfaceTraceableMessage- Parameters:
key- The key that the tracing context element should be stored under.value- The value to store under the given key.- Returns:
- the previous value stored under the given key if any present.
-
removeTracingContext
Description copied from interface:TraceableMessageRemoves some trace related context from the message.- Specified by:
removeTracingContextin interfaceTraceableMessage- Parameters:
key- The key of the tracing context element that should be cleared.- Returns:
- the previous value stored under the given key if any present.
-
getTracingAnnotation
Description copied from interface:TraceableMessageGets some trace specific message annotation that was previously applied to the given message either locally or by a remote peer.- Specified by:
getTracingAnnotationin interfaceTraceableMessage- Parameters:
key- The name of the tracing annotation data to retrieve.- Returns:
- the tracing related annotation data under the given key.
-
setTracingAnnotation
Description copied from interface:TraceableMessageSets some trace specific message annotation that was previously applied to the given message either locally or by a remote peer.- Specified by:
setTracingAnnotationin interfaceTraceableMessage- Parameters:
key- The name of the tracing annotation data to store the trace data under.value- The value to store under the given key.- Returns:
- the previous value stored under the given key if any present.
-
removeTracingAnnotation
Description copied from interface:TraceableMessageRemove some trace specific message annotation that was previously applied to the given message either locally or by a remote peer.- Specified by:
removeTracingAnnotationin interfaceTraceableMessage- Parameters:
key- The name of the tracing annotation data to remove.- Returns:
- the tracing related annotation data under the given key.
-
filterTracingAnnotations
Description copied from interface:TraceableMessageAllows the tracing layer to filter out tracing related details from the full set of message annotations that a message might be carrying.- Specified by:
filterTracingAnnotationsin interfaceTraceableMessage- Parameters:
filter- The filter used to consume tracing related message annotations of interest.
-