Class AMQPMessage

java.lang.Object
com.swiftmq.amqp.v100.messaging.AMQPMessage

public class AMQPMessage extends Object

AMQP message implementation.

The message may have different sections: Header, DeliveryAnnotations, MessageAnnotations, Properties, ApplicationProperties, a body and a Footer. The body is either one or more data sections, one or more AmqpSequence sections, or an AmqpValue section.

Author:
IIT Software GmbH, Bremen/Germany, (c) 2011, All Rights Reserved
  • Constructor Details

    • AMQPMessage

      public AMQPMessage(byte[] body) throws Exception
      Create an AMQP message which decodes itself out of a binary array.
      Parameters:
      body - binary array
      Throws:
      Exception - on error
    • AMQPMessage

      public AMQPMessage(byte[][] multiBody, int totalSize) throws Exception
      Create an AMQP message which decodes itself out of multiple binary arrays.
      Parameters:
      multiBody - multiple binary arrays
      totalSize - the totalSize of the arrays
      Throws:
      Exception - on error
    • AMQPMessage

      public AMQPMessage()
      Constructs an empty AMQP message.
  • Method Details

    • getBodySize

      public int getBodySize()
      Returns the size of the message
      Returns:
      size
    • setConsumer

      public void setConsumer(Consumer consumer)
      Sets the consumer which received this message. Internal use only.
      Parameters:
      consumer - Consumer
    • getTxnIdIF

      public TxnIdIF getTxnIdIF()
      Returns the transaction id.
      Returns:
      transaction id
    • setTxnIdIF

      public void setTxnIdIF(TxnIdIF txnIdIF)
      Sets the transaction id.
      Parameters:
      txnIdIF - transaction id.
    • accept

      public void accept() throws InvalidStateException
      Accepts delivery of this message. This is part of settlement with QoS modes at-least-once and exactly-once.
      Throws:
      InvalidStateException - If the state is invalid to perform this operation
    • reject

      public void reject() throws InvalidStateException

      Rejects delivery of this message. This is part of settlement with QoS modes at-least-once and exactly-once.

      This operation causes the delivery count to be incremented and the message to be redelivered to this or other competing consumers.

      Throws:
      InvalidStateException - If the state is invalid to perform this operation
    • getHeader

      public Header getHeader()
      Return the Header section.
      Returns:
      Header section
    • setHeader

      public void setHeader(Header header)
      Sets the Header section.
      Parameters:
      header - Header section
    • getDeliveryAnnotations

      public DeliveryAnnotations getDeliveryAnnotations()
      Returns the DeliveryAnnotations section.
      Returns:
      DeliveryAnnotations section
    • setDeliveryAnnotations

      public void setDeliveryAnnotations(DeliveryAnnotations deliveryAnnotations)
      Sets the DeliveryAnnotations section.
      Parameters:
      deliveryAnnotations - DeliveryAnnotations section
    • getMessageAnnotations

      public MessageAnnotations getMessageAnnotations()
      Returns the MessageAnnotations section.
      Returns:
      MessageAnnotations section
    • setMessageAnnotations

      public void setMessageAnnotations(MessageAnnotations messageAnnotations)
      Sets the MessageAnnotations section.
      Parameters:
      messageAnnotations - MessageAnnotations section
    • getProperties

      public Properties getProperties()
      Returns the Properties section.
      Returns:
      Properties section
    • setProperties

      public void setProperties(Properties properties)
      Sets the Properties section.
      Parameters:
      properties - Properties section
    • getApplicationProperties

      public ApplicationProperties getApplicationProperties()
      Returns the ApplicationProperties section.
      Returns:
      ApplicationProperties section
    • setApplicationProperties

      public void setApplicationProperties(ApplicationProperties applicationProperties)
      Sets the ApplicationProperties section.
      Parameters:
      applicationProperties - ApplicationProperties section
    • getData

      public List<Data> getData()
      Returns a list of Data body sections.
      Returns:
      list of Data body sections
    • addData

      public void addData(Data d)
      Add a Data body section.
      Parameters:
      d - Data body section
    • getAmqpSequence

      public List<AmqpSequence> getAmqpSequence()
      Returns a list of AmqpSequence body sections.
      Returns:
      list of AmqpSequence body sections
    • addAmqpSequence

      public void addAmqpSequence(AmqpSequence sequence)
      Add a AmqpSequence body section.
      Parameters:
      sequence - AmqpSequence body section
    • getAmqpValue

      public AmqpValue getAmqpValue()
      Returns the AmqpValue body section.
      Returns:
      AmqpValue body section
    • setAmqpValue

      public void setAmqpValue(AmqpValue amqpValue)
      Sets the AmqpValue body section.
      Parameters:
      amqpValue - AmqpValue body section
    • getFooter

      public Footer getFooter()
      Returns the Footer section.
      Returns:
      Footer section
    • setFooter

      public void setFooter(Footer footer)
      Sets the Footer section.
      Parameters:
      footer - Footer section
    • getDeliveryId

      public long getDeliveryId()
      Returns the delivery id.
      Returns:
      delivery id
    • setDeliveryId

      public void setDeliveryId(long deliveryId)
      Sets the delivery id.
      Parameters:
      deliveryId - delivery id
    • isSettled

      public boolean isSettled()

      Returns whether the message has been settled.

      A consumer has to check this after receive. If false is returned, the consumer must either call accept() or reject().
      Returns:
      settled or not
    • setSettled

      public void setSettled(boolean settled)
      Sets whether the message has been settled or not. Internal use only.
      Parameters:
      settled - settled or not
    • getDeliveryTag

      public DeliveryTag getDeliveryTag()
      Returns the delivery tag
      Returns:
      deliveryTag
    • setDeliveryTag

      public void setDeliveryTag(DeliveryTag deliveryTag)
      Sets the delivery tag
      Parameters:
      deliveryTag -
    • writeContent

      public void writeContent(DataOutput out) throws IOException
      Writes the content of this message to the data output.
      Parameters:
      out - data output
      Throws:
      IOException - on error
    • toString

      public String toString()
      Overrides:
      toString in class Object