Closed polaraditia closed 1 year ago
Per section 3.2 of the AMQP 1.0 spec, the data section, amqp-sequence section, or value section are mutually exclusive. To send a message using the value section, simply create a new Message
and populate the Value
field, no constructor required (will update the docs to clarify this).
msg := &Message{
Value: "something",
}
Please ping back if you have further questions.
Thanks for your explanations and updated docs
Please implement Message struct to support text message format payload (not bytes) since other MQ library for other language like NMS for C# have both ITextMessage and IByteMessage interface.
Actually, in current code, we can still stored the text payload in
message.Value
later after we create message usingNewMessage([]byte)
which stored payload inmessage.Data
. But some middlewares like I tested using ActiveMQ Artemis, it can't access (or maybe just ignored (?)) text stored inmessage.Value
and only display message bytes stored inmessage.Data
.As you can see in screenshot above, the message type (in Headers.type property) is detected as bytes and only displaying body with data stored in
message.Data
(contains Hello byte) not inmessage.Value
(contains Hello text).I tested creating consumer using C# with NMS library that try to consume the message treated as TextMessage with hope it can access text format parts of the message and the result is it can't read the message. And if the message is treated as ByteMessage it can access Hello byte only, not Hello text.
As workaround, we can make new additional NewMessage function with takes text parameter instead of []byte
Current code of message.go, message payload stored in bytes in
Data
field:We need add additional
NewMessageText
function with text parameter, message payload stored in string inValue
field:So it leave the
Data
field in message object blank/uninitialized (?) and only dataValue
contains payload. I tested using ActiveMQ Artemis, and finally, it can display message text stored inmessage.Value
(contains Hello text) with detected message type as text not byte.Thank you