Package com.swiftmq.amqp.v100.messaging
Class AMQPMessage
- java.lang.Object
-
- com.swiftmq.amqp.v100.messaging.AMQPMessage
-
public class AMQPMessage extends java.lang.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 Summary
Constructors Constructor Description AMQPMessage()
Constructs an empty AMQP message.AMQPMessage(byte[] body)
Create an AMQP message which decodes itself out of a binary array.AMQPMessage(byte[][] multiBody, int totalSize)
Create an AMQP message which decodes itself out of multiple binary arrays.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept()
Accepts delivery of this message.void
addAmqpSequence(AmqpSequence sequence)
Add a AmqpSequence body section.void
addData(Data d)
Add a Data body section.java.util.List<AmqpSequence>
getAmqpSequence()
Returns a list of AmqpSequence body sections.AmqpValue
getAmqpValue()
Returns the AmqpValue body section.ApplicationProperties
getApplicationProperties()
Returns the ApplicationProperties section.int
getBodySize()
Returns the size of the messagejava.util.List<Data>
getData()
Returns a list of Data body sections.DeliveryAnnotations
getDeliveryAnnotations()
Returns the DeliveryAnnotations section.long
getDeliveryId()
Returns the delivery id.DeliveryTag
getDeliveryTag()
Returns the delivery tagFooter
getFooter()
Returns the Footer section.Header
getHeader()
Return the Header section.MessageAnnotations
getMessageAnnotations()
Returns the MessageAnnotations section.Properties
getProperties()
Returns the Properties section.TxnIdIF
getTxnIdIF()
Returns the transaction id.boolean
isSettled()
Returns whether the message has been settled.void
reject()
Rejects delivery of this message.void
setAmqpValue(AmqpValue amqpValue)
Sets the AmqpValue body section.void
setApplicationProperties(ApplicationProperties applicationProperties)
Sets the ApplicationProperties section.void
setConsumer(Consumer consumer)
Sets the consumer which received this message.void
setDeliveryAnnotations(DeliveryAnnotations deliveryAnnotations)
Sets the DeliveryAnnotations section.void
setDeliveryId(long deliveryId)
Sets the delivery id.void
setDeliveryTag(DeliveryTag deliveryTag)
Sets the delivery tagvoid
setFooter(Footer footer)
Sets the Footer section.void
setHeader(Header header)
Sets the Header section.void
setMessageAnnotations(MessageAnnotations messageAnnotations)
Sets the MessageAnnotations section.void
setProperties(Properties properties)
Sets the Properties section.void
setSettled(boolean settled)
Sets whether the message has been settled or not.void
setTxnIdIF(TxnIdIF txnIdIF)
Sets the transaction id.java.lang.String
toString()
void
writeContent(java.io.DataOutput out)
Writes the content of this message to the data output.
-
-
-
Constructor Detail
-
AMQPMessage
public AMQPMessage(byte[] body) throws java.lang.Exception
Create an AMQP message which decodes itself out of a binary array.- Parameters:
body
- binary array- Throws:
java.lang.Exception
- on error
-
AMQPMessage
public AMQPMessage(byte[][] multiBody, int totalSize) throws java.lang.Exception
Create an AMQP message which decodes itself out of multiple binary arrays.- Parameters:
multiBody
- multiple binary arraystotalSize
- the totalSize of the arrays- Throws:
java.lang.Exception
- on error
-
AMQPMessage
public AMQPMessage()
Constructs an empty AMQP message.
-
-
Method Detail
-
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 java.util.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 java.util.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(java.io.DataOutput out) throws java.io.IOException
Writes the content of this message to the data output.- Parameters:
out
- data output- Throws:
java.io.IOException
- on error
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-