Package com.swiftmq.amqp.v100.messaging
Class AMQPMessage
java.lang.Object
com.swiftmq.amqp.v100.messaging.AMQPMessage
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
ConstructorsConstructorDescriptionConstructs 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
Modifier and TypeMethodDescriptionvoid
accept()
Accepts delivery of this message.void
addAmqpSequence
(AmqpSequence sequence) Add a AmqpSequence body section.void
Add a Data body section.Returns a list of AmqpSequence body sections.Returns the AmqpValue body section.Returns the ApplicationProperties section.int
Returns the size of the messagegetData()
Returns a list of Data body sections.Returns the DeliveryAnnotations section.long
Returns the delivery id.Returns the delivery tagReturns the Footer section.Return the Header section.Returns the MessageAnnotations section.Returns the Properties section.Returns the transaction id.boolean
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
Sets the Footer section.void
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.toString()
void
writeContent
(DataOutput out) Writes the content of this message to the data output.
-
Constructor Details
-
AMQPMessage
Create an AMQP message which decodes itself out of a binary array.- Parameters:
body
- binary array- Throws:
Exception
- on error
-
AMQPMessage
Create an AMQP message which decodes itself out of multiple binary arrays.- Parameters:
multiBody
- multiple binary arraystotalSize
- 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
Sets the consumer which received this message. Internal use only.- Parameters:
consumer
- Consumer
-
getTxnIdIF
Returns the transaction id.- Returns:
- transaction id
-
setTxnIdIF
Sets the transaction id.- Parameters:
txnIdIF
- transaction id.
-
accept
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
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
Return the Header section.- Returns:
- Header section
-
setHeader
Sets the Header section.- Parameters:
header
- Header section
-
getDeliveryAnnotations
Returns the DeliveryAnnotations section.- Returns:
- DeliveryAnnotations section
-
setDeliveryAnnotations
Sets the DeliveryAnnotations section.- Parameters:
deliveryAnnotations
- DeliveryAnnotations section
-
getMessageAnnotations
Returns the MessageAnnotations section.- Returns:
- MessageAnnotations section
-
setMessageAnnotations
Sets the MessageAnnotations section.- Parameters:
messageAnnotations
- MessageAnnotations section
-
getProperties
Returns the Properties section.- Returns:
- Properties section
-
setProperties
Sets the Properties section.- Parameters:
properties
- Properties section
-
getApplicationProperties
Returns the ApplicationProperties section.- Returns:
- ApplicationProperties section
-
setApplicationProperties
Sets the ApplicationProperties section.- Parameters:
applicationProperties
- ApplicationProperties section
-
getData
Returns a list of Data body sections.- Returns:
- list of Data body sections
-
addData
Add a Data body section.- Parameters:
d
- Data body section
-
getAmqpSequence
Returns a list of AmqpSequence body sections.- Returns:
- list of AmqpSequence body sections
-
addAmqpSequence
Add a AmqpSequence body section.- Parameters:
sequence
- AmqpSequence body section
-
getAmqpValue
Returns the AmqpValue body section.- Returns:
- AmqpValue body section
-
setAmqpValue
Sets the AmqpValue body section.- Parameters:
amqpValue
- AmqpValue body 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
Returns the delivery tag- Returns:
- deliveryTag
-
setDeliveryTag
Sets the delivery tag- Parameters:
deliveryTag
-
-
writeContent
Writes the content of this message to the data output.- Parameters:
out
- data output- Throws:
IOException
- on error
-
toString
-