Class AmqpJmsMessageFacade

    • Constructor Detail

      • AmqpJmsMessageFacade

        public AmqpJmsMessageFacade()
    • Method Detail

      • initialize

        public void initialize​(AmqpConnection connection)
        Initialize the state of this message for send.
        Parameters:
        connection - The connection that this message is linked to.
      • initialize

        public void initialize​(AmqpConsumer consumer)
        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

        public boolean propertyExists​(String key)
                               throws javax.jms.JMSException
        Specified by:
        propertyExists in interface JmsMessageFacade
        Parameters:
        key - The property name that is being searched for.
        Returns:
        true if the given property exists within the message.
        Throws:
        javax.jms.JMSException - if an error occurs while accessing the Message properties.
      • applicationPropertyExists

        public boolean applicationPropertyExists​(String key)
                                          throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • getPropertyNames

        public Set<String> 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:
        getPropertyNames in interface JmsMessageFacade
        Returns:
        a set of property names in the message or an empty set if none are set.
      • getApplicationPropertyNames

        public Set<String> getApplicationPropertyNames​(Set<String> propertyNames)
      • getProperty

        public Object getProperty​(String key)
                           throws javax.jms.JMSException
        Description copied from interface: JmsMessageFacade
        Returns the property stored in the message accessed via the given key/
        Specified by:
        getProperty in interface JmsMessageFacade
        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:
        javax.jms.JMSException - if an error occurs while accessing the Message properties.
      • getApplicationProperty

        public Object getApplicationProperty​(String key)
                                      throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • setProperty

        public void setProperty​(String key,
                                Object value)
                         throws javax.jms.JMSException
        Description copied from interface: JmsMessageFacade
        Sets the message property value using the supplied key to identify the value that should be set or updated.
        Specified by:
        setProperty in interface JmsMessageFacade
        Parameters:
        key - the key that identifies the message property.
        value - the value that is to be stored in the message.
        Throws:
        javax.jms.JMSException - if an error occurs while accessing the Message properties.
      • setApplicationProperty

        public void setApplicationProperty​(String key,
                                           Object value)
                                    throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • onSend

        public void onSend​(long producerTtl)
                    throws javax.jms.JMSException
        Description copied from interface: JmsMessageFacade
        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. 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:
        onSend in interface JmsMessageFacade
        Parameters:
        producerTtl - the time to live value configured on the producer when sent.
        Throws:
        javax.jms.JMSException - if an error occurs while preparing the message for send.
      • onDispatch

        public void onDispatch()
                        throws javax.jms.JMSException
        Description copied from interface: JmsMessageFacade
        Called 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:
        onDispatch in interface JmsMessageFacade
        Throws:
        javax.jms.JMSException - if an error occurs while preparing the message for dispatch.
      • clearProperties

        public void clearProperties()
                             throws javax.jms.JMSException
        Description copied from interface: JmsMessageFacade
        Clears any Message properties that exist for this Message instance.
        Specified by:
        clearProperties in interface JmsMessageFacade
        Throws:
        javax.jms.JMSException - if an error occurs while accessing the message properties.
      • copy

        public AmqpJmsMessageFacade copy()
                                  throws javax.jms.JMSException
        Description copied from interface: JmsMessageFacade
        Create a new instance and perform a deep copy of this object's contents.
        Specified by:
        copy in interface JmsMessageFacade
        Returns:
        a copy of this JmsMessageFacade instance.
        Throws:
        javax.jms.JMSException - if an error occurs while copying the message.
      • getMessageId

        public String getMessageId()
        Description copied from interface: JmsMessageFacade
        Returns the message ID set on this message if one exists, null otherwise. The returned value will include the JMS mandated 'ID:' prefix.
        Specified by:
        getMessageId in interface JmsMessageFacade
        Returns:
        the set message ID or null if not set.
      • getProviderMessageIdObject

        public Object getProviderMessageIdObject()
        Description copied from interface: JmsMessageFacade
        Returns 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:
        getProviderMessageIdObject in interface JmsMessageFacade
        Returns:
        the set provider message ID or null if not set.
      • setProviderMessageIdObject

        public void setProviderMessageIdObject​(Object messageId)
        Description copied from interface: JmsMessageFacade
        Sets the underlying providers message ID object for this message, or clears it if the provided value is null.
        Specified by:
        setProviderMessageIdObject in interface JmsMessageFacade
        Parameters:
        messageId - The message ID to set on this message, or null to clear.
      • getTimestamp

        public long getTimestamp()
        Description copied from interface: JmsMessageFacade
        Gets the time stamp assigned to the message when it was sent.
        Specified by:
        getTimestamp in interface JmsMessageFacade
        Returns:
        the message time stamp value.
      • setTimestamp

        public void setTimestamp​(long timestamp)
        Description copied from interface: JmsMessageFacade
        Sets the time stamp value of this message.
        Specified by:
        setTimestamp in interface JmsMessageFacade
        Parameters:
        timestamp - the time that the message was sent by the provider.
      • getCorrelationId

        public String getCorrelationId()
        Description copied from interface: JmsMessageFacade
        Returns 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:
        getCorrelationId in interface JmsMessageFacade
        Returns:
        the set correlation ID or null if not set.
      • getCorrelationIdBytes

        public byte[] getCorrelationIdBytes()
                                     throws javax.jms.JMSException
        Description copied from interface: JmsMessageFacade
        Gets 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:
        getCorrelationIdBytes in interface JmsMessageFacade
        Returns:
        a byte array containing the correlation ID value in raw form.
        Throws:
        javax.jms.JMSException - if an error occurs while accessing the property.
      • setCorrelationIdBytes

        public void setCorrelationIdBytes​(byte[] correlationId)
        Description copied from interface: JmsMessageFacade
        Sets 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:
        setCorrelationIdBytes in interface JmsMessageFacade
        Parameters:
        correlationId - the byte array to use to set the message correlation ID.
      • isPersistent

        public boolean isPersistent()
        Specified by:
        isPersistent in interface JmsMessageFacade
        Returns:
        true if this message is tagged as being persistent.
      • setPersistent

        public void setPersistent​(boolean value)
        Description copied from interface: JmsMessageFacade
        Sets the persistent flag on this message.
        Specified by:
        setPersistent in interface JmsMessageFacade
        Parameters:
        value - true if the message is to be marked as persistent.
      • getDeliveryCount

        public int getDeliveryCount()
        Description copied from interface: JmsMessageFacade
        Returns the current delivery count of the Message as set in the underlying message instance.
        Specified by:
        getDeliveryCount in interface JmsMessageFacade
        Returns:
        the current delivery count.
      • setDeliveryCount

        public void setDeliveryCount​(int deliveryCount)
        Description copied from interface: JmsMessageFacade
        Sets the delivery count on the message.
        Specified by:
        setDeliveryCount in interface JmsMessageFacade
        Parameters:
        deliveryCount - the new delivery count to assign the Message.
      • getRedeliveryCount

        public int getRedeliveryCount()
        Description copied from interface: JmsMessageFacade
        Returns the current redelivery count of the Message as set in the underlying message instance.
        Specified by:
        getRedeliveryCount in interface JmsMessageFacade
        Returns:
        the current redelivery count.
      • setRedeliveryCount

        public void setRedeliveryCount​(int redeliveryCount)
        Description copied from interface: JmsMessageFacade
        Used to update the message redelivery after a local redelivery of the Message has been performed.
        Specified by:
        setRedeliveryCount in interface JmsMessageFacade
        Parameters:
        redeliveryCount - the new redelivery count to assign the Message.
      • isRedelivered

        public boolean isRedelivered()
        Description copied from interface: JmsMessageFacade
        Used to quickly check if a message has been redelivered.
        Specified by:
        isRedelivered in interface JmsMessageFacade
        Returns:
        true if the message was redelivered, false otherwise.
      • setRedelivered

        public void setRedelivered​(boolean redelivered)
        Description copied from interface: JmsMessageFacade
        Used 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:
        setRedelivered in interface JmsMessageFacade
        Parameters:
        redelivered - true if the message is to be marked as redelivered, false otherwise.
      • getType

        public String getType()
        Description copied from interface: JmsMessageFacade
        Returns the JMSType value as defined by the provider or set by the sending client.
        Specified by:
        getType in interface JmsMessageFacade
        Returns:
        a String value that defines the message JMSType.
      • setType

        public void setType​(String type)
        Description copied from interface: JmsMessageFacade
        Sets the String value used to define the Message JMSType by the client.
        Specified by:
        setType in interface JmsMessageFacade
        Parameters:
        type - the JMSType value the client assigns to this message.
      • getPriority

        public int getPriority()
        Description copied from interface: JmsMessageFacade
        Returns 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:
        getPriority in interface JmsMessageFacade
        Returns:
        the priority value assigned to this message.
      • setPriority

        public void setPriority​(int priority)
        Description copied from interface: JmsMessageFacade
        Sets the message priority for this message using a JMS priority scoped value.
        Specified by:
        setPriority in interface JmsMessageFacade
        Parameters:
        priority - the new priority value to set on this message.
      • getExpiration

        public long getExpiration()
        Description copied from interface: JmsMessageFacade
        Returns the set expiration time for this message. The value should be returned as an absolute time given in GMT time.
        Specified by:
        getExpiration in interface JmsMessageFacade
        Returns:
        the time that this message expires or zero if it never expires.
      • setExpiration

        public void setExpiration​(long expiration)
        Description copied from interface: JmsMessageFacade
        Sets an expiration time on this message. The expiration time will be given as an absolute time in GMT time.
        Specified by:
        setExpiration in interface JmsMessageFacade
        Parameters:
        expiration - the time that this message should be considered as expired.
      • getDeliveryTime

        public long getDeliveryTime()
        Description copied from interface: JmsMessageFacade
        Returns the set delivery time for this message. The value should be returned as an absolute time given in GMT time.
        Specified by:
        getDeliveryTime in interface JmsMessageFacade
        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: JmsMessageFacade
        Sets an desired delivery time on this message. The delivery time will be given as an absolute time in GMT time.
        Specified by:
        setDeliveryTime in interface JmsMessageFacade
        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: JmsMessageFacade
        Returns whether the delivery time is being transmitted, i.e. incorporates an actual delivery delay.
        Specified by:
        isDeliveryTimeTransmitted in interface JmsMessageFacade
        Returns:
        true if delivery time is being transmitted as an annotation
      • setAmqpTimeToLiveOverride

        public void setAmqpTimeToLiveOverride​(Long ttl)
                                       throws javax.jms.MessageFormatException
        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:
        javax.jms.MessageFormatException - if the TTL value is not in the allowed range.
      • hasAmqpTimeToLiveOverride

        public boolean hasAmqpTimeToLiveOverride()
      • getAmqpTimeToLiveOverride

        public long getAmqpTimeToLiveOverride()
      • getDestination

        public JmsDestination getDestination()
        Description copied from interface: JmsMessageFacade
        Gets the Destination value that was assigned to this message at the time it was sent.
        Specified by:
        getDestination in interface JmsMessageFacade
        Returns:
        the destination to which this message was originally sent.
      • setDestination

        public void setDestination​(JmsDestination destination)
        Description copied from interface: JmsMessageFacade
        Sets the Destination that this message is being sent to.
        Specified by:
        setDestination in interface JmsMessageFacade
        Parameters:
        destination - the destination that this message is being sent to.
      • getReplyTo

        public JmsDestination getReplyTo()
        Description copied from interface: JmsMessageFacade
        Gets the Destination where replies for this Message are to be sent to.
        Specified by:
        getReplyTo in interface JmsMessageFacade
        Returns:
        the reply to destination for this message or null if none set.
      • setReplyTo

        public void setReplyTo​(JmsDestination replyTo)
        Description copied from interface: JmsMessageFacade
        Sets the Destination where replies to this Message are to be sent.
        Specified by:
        setReplyTo in interface JmsMessageFacade
        Parameters:
        replyTo - the Destination where replies should be sent, or null to clear.
      • setReplyToGroupId

        public void setReplyToGroupId​(String replyToGroupId)
      • getReplyToGroupId

        public String getReplyToGroupId()
      • getUserId

        public String getUserId()
        Description copied from interface: JmsMessageFacade
        Returns the ID of the user that sent this message if available.
        Specified by:
        getUserId in interface JmsMessageFacade
        Returns:
        the user ID that was in use when this message was sent or null if not set.
      • setUserId

        public void setUserId​(String userId)
        Description copied from interface: JmsMessageFacade
        Sets the User ID for the connection that is being used to send this message.
        Specified by:
        setUserId in interface JmsMessageFacade
        Parameters:
        userId - the user ID that sent this message or null to clear.
      • getUserIdBytes

        public byte[] getUserIdBytes()
        Description copied from interface: JmsMessageFacade
        Gets 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:
        getUserIdBytes in interface JmsMessageFacade
        Returns:
        a byte array containing the user ID value in raw form.
      • setUserIdBytes

        public void setUserIdBytes​(byte[] userId)
        Description copied from interface: JmsMessageFacade
        Sets 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:
        setUserIdBytes in interface JmsMessageFacade
        Parameters:
        userId - the byte array to use to set the message user ID.
      • getGroupId

        public String getGroupId()
        Description copied from interface: JmsMessageFacade
        Gets the Group ID that this message is assigned to.
        Specified by:
        getGroupId in interface JmsMessageFacade
        Returns:
        the Group ID this message was sent in.
      • setGroupId

        public void setGroupId​(String groupId)
        Description copied from interface: JmsMessageFacade
        Sets the Group ID to use for this message.
        Specified by:
        setGroupId in interface JmsMessageFacade
        Parameters:
        groupId - the Group ID that this message is assigned to.
      • getGroupSequence

        public int getGroupSequence()
        Description copied from interface: JmsMessageFacade
        Gets the assigned group sequence of this message.
        Specified by:
        getGroupSequence in interface JmsMessageFacade
        Returns:
        the assigned group sequence of this message.
      • setGroupSequence

        public void setGroupSequence​(int groupSequence)
        Description copied from interface: JmsMessageFacade
        Sets the group sequence value for this message.
        Specified by:
        setGroupSequence in interface JmsMessageFacade
        Parameters:
        groupSequence - the group sequence value to assign this message.
      • hasBody

        public boolean hasBody()
        Description copied from interface: JmsMessageFacade
        Returns true if the underlying message has a body, false if the body is empty.
        Specified by:
        hasBody in interface JmsMessageFacade
        Returns:
        true if the underlying message has a body, false if the body is empty.
      • encodeMessage

        public io.netty.buffer.ByteBuf encodeMessage()
        Description copied from interface: JmsMessageFacade
        Encodes the protocol level Message instance for transmission.
        Specified by:
        encodeMessage in interface JmsMessageFacade
        Returns:
        an Object that represents the encoded form of the message for the target provider.
      • getTracingContext

        public Object getTracingContext​(String key)
        Description copied from interface: TraceableMessage
        Gets 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:
        getTracingContext in interface TraceableMessage
        Parameters:
        key - The name of the context element to be looked up.
        Returns:
        the stored tracing context element or null if not present.
      • setTracingContext

        public Object setTracingContext​(String key,
                                        Object value)
        Description copied from interface: TraceableMessage
        Sets 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:
        setTracingContext in interface TraceableMessage
        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

        public Object removeTracingContext​(String key)
        Description copied from interface: TraceableMessage
        Removes some trace related context from the message.
        Specified by:
        removeTracingContext in interface TraceableMessage
        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

        public Object getTracingAnnotation​(String key)
        Description copied from interface: TraceableMessage
        Gets some trace specific message annotation that was previously applied to the given message either locally or by a remote peer.
        Specified by:
        getTracingAnnotation in interface TraceableMessage
        Parameters:
        key - The name of the tracing annotation data to retrieve.
        Returns:
        the tracing related annotation data under the given key.
      • setTracingAnnotation

        public Object setTracingAnnotation​(String key,
                                           Object value)
        Description copied from interface: TraceableMessage
        Sets some trace specific message annotation that was previously applied to the given message either locally or by a remote peer.
        Specified by:
        setTracingAnnotation in interface TraceableMessage
        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

        public Object removeTracingAnnotation​(String key)
        Description copied from interface: TraceableMessage
        Remove some trace specific message annotation that was previously applied to the given message either locally or by a remote peer.
        Specified by:
        removeTracingAnnotation in interface TraceableMessage
        Parameters:
        key - The name of the tracing annotation data to remove.
        Returns:
        the tracing related annotation data under the given key.
      • filterTracingAnnotations

        public void filterTracingAnnotations​(BiConsumer<String,​Object> filter)
        Description copied from interface: TraceableMessage
        Allows the tracing layer to filter out tracing related details from the full set of message annotations that a message might be carrying.
        Specified by:
        filterTracingAnnotations in interface TraceableMessage
        Parameters:
        filter - The filter used to consume tracing related message annotations of interest.