Skip to content

Message Compatibility with AMQP 0.9.x #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
luizcarlosfaria opened this issue Apr 20, 2025 · 5 comments · Fixed by #116
Closed

Message Compatibility with AMQP 0.9.x #115

luizcarlosfaria opened this issue Apr 20, 2025 · 5 comments · Fixed by #116
Labels
enhancement New feature or request

Comments

@luizcarlosfaria
Copy link

Is your feature request related to a problem? Please describe.

Trying to publish with RabbitMQ.AMQP.Client 0.1.0 and 0.2.0-beta.0 and consume with regular RabbitMQ.Client, I've seen a prefix in message body.

How to produce the message:

 string text = JsonConvert.SerializeObject(message); //produces {"Text":"as","Seq":1,"Max":7000} 
 byte[] body = System.Text.Encoding.UTF8.GetBytes(text);
 IMessage amqpMessage = new AmqpMessage(body).ToAddress().Exchange(exchange).Key(routingKey).Build();
...
PublishResult result = await publisher.PublishAsync(message: amqpMessage, cancellationToken: cancellationToken).ConfigureAwait(configureAwait);

But when use Management to see what's is send (because consumers can't read this message) I've found some new behavior:

  1. Message is sent as base64 (on amqp 0.9.x i can see {"Text":"test","Seq":1,"Max":7000} , but with amqp 1x it's a base64 version AFN3oSB7IlRleHQiOiJhcyIsIlNlcSI6MSwiTWF4Ijo3MDAwfQ==
  2. When open this message a prefix cause add to body, you can see at https://dotnetfiddle.net/xd9qun

I've tryed to decode in some formats to understand:

Unicode (UTF-8): Sw� {"Text":"as","Seq":1,"Max":7000} 
Western European (ISO): Sw¡ {"Text":"as","Seq":1,"Max":7000} 
US-ASCII: Sw? {"Text":"as","Seq":1,"Max":7000} 
Unicode: 匀ꅷ笠吢硥≴∺獡Ⱒ匢煥㨢ⰱ䴢硡㨢〷〰� 
Unicode (Big-Endian): S瞡⁻≔數琢㨢慳∬≓敱∺ㄬ≍慸∺㜰〰� 
Unicode (UTF-8): Sw� {"Text":"as","Seq":1,"Max":7000} 
Unicode (UTF-7): Sw¡ {"Text":"as","Seq":1,"Max":7000} 

The base64 is easy to handle because the amqp message has type attribute.

But the prefix, I can't understand how handler

Describe the solution you'd like

  • Verify if this is a default behavior or a bug.
  • Explain how to handle this prefix (maybe defining a transport configuration).

Describe alternatives you've considered

No response

Additional context

No response

@luizcarlosfaria luizcarlosfaria added the enhancement New feature or request label Apr 20, 2025
@Gsantomaggio
Copy link
Member

Hi @luizcarlosfaria,
Thank you for reporting the issue. We will have a look as soon as possible.

@Gsantomaggio
Copy link
Member

What you see as "Sw�" is:

0] = {byte} 0
[1] = {byte} 83 // TypeCodeSmallUlong
[2] = {byte} 119 // TypeCodeAMQPValue
[3] = {byte} // not relevant 

The AmqpValue type encoding added by the server: https://www.rabbitmq.com/docs/next/conversions#amqp-amqpl

PR #116 resolves the issue by changing the default from AMQPValue to ApplicationData, which is more appropriate for cross-protocol applications

@luizcarlosfaria
Copy link
Author

Really thank you, @Gsantomaggio today I'll test it.

@luizcarlosfaria
Copy link
Author

luizcarlosfaria commented Apr 28, 2025

@Gsantomaggio last April 23, I've tested and it works!! Thank you.

@Gsantomaggio
Copy link
Member

Great ! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants