Interface JmsMessage<PAYLOAD>

Type Parameters:
PAYLOAD - Type of the payload.
All Superinterfaces:
Message<PAYLOAD>
All Known Subinterfaces:
AqMessage<T>
All Known Implementing Classes:
JmsBytesMessage, JmsTextMessage

public interface JmsMessage<PAYLOAD> extends Message<PAYLOAD>
Message representing JMS message together with all the metadata.
  • Method Details

    • getJmsSession

      jakarta.jms.Session getJmsSession()
      Metadata about the JMS session.
      Returns:
      JMS session
    • getJmsConnection

      jakarta.jms.Connection getJmsConnection()
      Get client's connection to its JMS provider.
      Returns:
      JMS connection
    • getJmsConnectionFactory

      jakarta.jms.ConnectionFactory getJmsConnectionFactory()
      Get JMS connection factory.
      Returns:
      JMS connection factory
    • getJmsMessage

      <MSG extends jakarta.jms.Message> MSG getJmsMessage()
      Original JMS message received.
      Type Parameters:
      MSG - expected sub-type of Message
      Returns:
      original JMS message received
      Throws:
      ClassCastException - when original payload cannot be casted to expected type
    • getType

      default String getType()
      Return type identifier set by sending JMS client.
      Returns:
      JMS type or null
    • getCorrelationId

      default String getCorrelationId()
      Return correlation id of the message.
      Returns:
      correlation id or null
    • getReplyTo

      default jakarta.jms.Destination getReplyTo()
      Return reply to destination of the message.
      Returns:
      destination or null
    • isAck

      boolean isAck()
      Check if message has been acknowledged yet.
      Returns:
      true if message has been acknowledged
    • getProperty

      <P> P getProperty(String name)
      Get JMS property by name.
      Type Parameters:
      P - expected type of the property, has to be Boolean, Byte, Short, Integer, Long, Float, Double or String
      Parameters:
      name - the name of the JMS property
      Returns:
      property value with the specified name or null
      Throws:
      ClassCastException - when property cannot be casted to expected type
    • hasProperty

      boolean hasProperty(String name)
      Check if JMS property exists.
      Parameters:
      name - the name of the JMS property
      Returns:
      true if property exists
    • getPropertyNames

      Set<String> getPropertyNames()
      Return set of all JMS property names.
      Returns:
      JMS property names
    • of

      static <PAYLOAD> Message<PAYLOAD> of(PAYLOAD payload, Supplier<CompletionStage<Void>> ack)
      Create a JmsMessage with the given payload and ack function.
      Type Parameters:
      PAYLOAD - the type of payload
      Parameters:
      payload - The payload.
      ack - The ack function, this will be invoked when the returned messages Message.ack() method is invoked.
      Returns:
      A message with the given payload and ack function.
    • of

      static <PAYLOAD> Message<PAYLOAD> of(PAYLOAD payload)
      Create a JmsMessage with the given payload.
      Type Parameters:
      PAYLOAD - The type of payload
      Parameters:
      payload - The payload.
      Returns:
      A message with the given payload, and a no-op ack function.
    • builder

      static <PAYLOAD> JmsMessage.OutgoingJmsMessageBuilder<PAYLOAD> builder(PAYLOAD payload)
      Outgoing JMS message builder. Makes possible to create JMS message with properties.
      Type Parameters:
      PAYLOAD - JMS message payload type
      Parameters:
      payload - JMS message payload
      Returns:
      Message builder
    • builder

      static <PAYLOAD> JmsMessage.OutgoingJmsMessageBuilder<PAYLOAD> builder(jakarta.jms.Message msg)
      Outgoing JMS message builder. Makes possible to create JMS message from Message and customize result. Does NOT copy payload, only headers and properties.
      Type Parameters:
      PAYLOAD - payload type
      Parameters:
      msg - Message to derive metadata
      Returns:
      Message builder
      Throws:
      MessagingException - when JMS provider can't retrieve message body, properties or metadata
    • builder

      static <PAYLOAD> JmsMessage.OutgoingJmsMessageBuilder<PAYLOAD> builder()
      Outgoing JMS message builder. Makes possible to create JMS message with properties.
      Type Parameters:
      PAYLOAD - JMS message payload type
      Returns:
      Message builder