public interface Message
Message
interface is the root interface of all OMS messages, and the most commonly used OMS message is
Message
.
Most message-oriented middleware (MOM) products treat messages as lightweight entities that consist of header and body and is used by separate applications to exchange a piece of information, like Apache RocketMQ.
The header contains fields used by the messaging system that describes the message's meta information, while the body contains the application data being transmitted.
As for the message header, OMS defines three kinds types: headers Header
ExtensionHeader
and
properties KeyValue
, with respect to flexibility in vendor implementation and user usage.
In BytesMessage, the body is just a byte array, may be compressed and uncompressed in the transmitting process by the
messaging system. The application is responsible for explaining the concrete content and format of the message body,
OMS is never aware of that.
The body part is placed in the implementation classes of Message
.
Modifier and Type | Method and Description |
---|---|
ExtensionHeader |
extensionHeader()
This interface is optional, Therefore, users need to check whether the interface is implemented and the
correctness of its implementation.
|
byte[] |
getData()
Get data from message body
|
MessageReceipt |
getMessageReceipt()
Get the
MessageReceipt of this Message, which will be used to acknowledge this message. |
Header |
header()
Returns all the system header fields of the
Message object as a KeyValue . |
KeyValue |
properties()
Returns all the customized user header fields of the
Message object as a KeyValue . |
void |
setData(byte[] data)
Set data to message body
|
Header header()
Message
object as a KeyValue
.Message
@Optional ExtensionHeader extensionHeader()
ExtensionHeader
KeyValue properties()
Message
object as a KeyValue
.Message
byte[] getData()
OMSMessageFormatException
- if the message body cannot be assigned to the specified typevoid setData(byte[] data)
data
- set message body in binary streamMessageReceipt getMessageReceipt()
MessageReceipt
of this Message, which will be used to acknowledge this message.Consumer.ack(io.openmessaging.consumer.MessageReceipt)
,
MessageListener.Context#ack()
,
BatchMessageListener.Context#success(io.openmessaging.consumer.MessageReceipt...)
Copyright © 2017–2020 OpenMessaging. All rights reserved.