Class IncomingRabbitMQMetadata


  • public class IncomingRabbitMQMetadata
    extends Object
    Holds metadata from an incoming RabbitMQ message.
    • Method Detail

      • getHeader

        public <T> Optional<T> getHeader​(String header,
                                         Class<T> type)
        Retrieves the header value cast to the required type.
        Type Parameters:
        T - the type
        Parameters:
        header - the name of the header
        type - the required type
        Returns:
        the cast header value, which may be empty if the header is not present
        Throws:
        IllegalArgumentException - if the header value could not be cast as required
      • getHeaders

        public Map<String,​Object> getHeaders()
        The headers property is a key/value map that allows for arbitrary, user-defined keys and values. Keys are string values that have a maximum length of 255 characters. Values can be any valid AMQP value type; this includes String, Long, Boolean and List.

        List values may contain a mixture of other values of any of the above types (including List).

        Returns:
        the message headers as an unmodifiable Map
      • getContentType

        public Optional<String> getContentType()
        The RFC-2046 MIME type for the message's application-data section (body). As per RFC-2046 this can contain a charset parameter defining the character encoding used: e.g., 'text/plain; charset="utf-8"'.

        If the payload is known to be truly opaque binary data, the content-type should be set to application/octet-stream.

        Stored in the message properties.

        Returns:
        an Optional containing the content-type, which may be empty if no content-type was received
      • getContentEncoding

        public Optional<String> getContentEncoding()
        The content-encoding property is used as a modifier to the content-type. When present, its value indicates what additional content encodings have been applied to the application-data, and thus what decoding mechanisms need to be applied in order to obtain the media-type referenced by the content-type header field.

        Stored in the message properties.

        Returns:
        an Optional containing the content-encoding, which may be empty if no content-encoding was received
      • getCreationTime

        public Optional<ZonedDateTime> getCreationTime​(ZoneId zoneId)
        The absolute time when this message was created, expressed as a ZonedDateTime with respect to the supplied ZoneId.

        Stored in the message properties.

        Parameters:
        zoneId - the ZoneId representing the time zone in which the timestamp is to be interpreted
        Returns:
        an Optional containing the date and time, which may be empty if no timestamp was received
      • getId

        public Optional<String> getId()
        The message-id, if set, uniquely identifies a message within the message system. The message producer is usually responsible for setting the message-id in such a way that it is assured to be globally unique. A broker may discard a message as a duplicate if the value of the message-id matches that of a previously received message sent to the same node.

        Stored in the message properties.

        Returns:
        an Optional containing the message-id, which may be empty if no message-id was received
      • getUserId

        public Optional<String> getUserId()
        The identity of the user responsible for producing the message. The client sets this value, and it may be authenticated by intermediaries.

        Stored in the message properties.

        Returns:
        an Optional containing the user-id, which may be empty if no user-id was received
      • getPriority

        public Optional<Integer> getPriority()
        This priority field contains the relative message priority. Higher numbers indicate higher priority messages. Messages with higher priorities may be delivered before those with lower priorities.

        Stored in the message properties.

        Returns:
        an Optional containing the priority, which may be empty if no priority was received
      • getReplyTo

        public Optional<String> getReplyTo()
        The address of the node to send replies to.

        Stored in the message properties.

        Returns:
        an Optional containing the reply-to address, which may be empty if no reply-to was received
      • getCorrelationId

        public Optional<String> getCorrelationId()
        This is a client-specific id that can be used to mark or identify messages between clients.

        Stored in the message properties.

        Returns:
        an Optional containing the correlation-id, which may be empty if no correlation-id was received
      • getExchange

        public String getExchange()
        The exchange the message was delivered to.

        Stored in the message envelope.

        Returns:
        the name of the message's exchange.
      • getRoutingKey

        public String getRoutingKey()
        The routing key for the exchange the message was delivered to.

        Stored in the message envelope.

        Returns:
        the message's routing key.
      • isRedeliver

        public boolean isRedeliver()
        This is a hint as to whether this message may have been delivered before (but not acknowledged). If the flag is not set, the message definitely has not been delivered before. If it is set, it may have been delivered before.

        Stored in the message envelope.

        Returns:
        the message's redelivery flag.