Skip to content
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

Byte conversion support #579

Merged
merged 4 commits into from
Mar 20, 2019
Merged

Byte conversion support #579

merged 4 commits into from
Mar 20, 2019

Conversation

sergeyshaykhullin
Copy link
Contributor

@sergeyshaykhullin sergeyshaykhullin commented Mar 19, 2019

Proposed Changes

I tried to add byte conversion support for arguments. but this not a final version. Solutions are:

  1. Add new byte case and write as byte
  2. Add new byte case and write as int/short
  3. Do nothing because has int-workaround

Motivation:
RabbitMQ has x-max-priority for queues, x-priority for consumers and priority in IBasicProperties for producers, but for them is ok. Commonly i used them to balance messages.
Priorities is in 1...255 range and perfectly suites to byte, but when i tried wrap arguments with byte extensions i got a WireFormattingException(Value cannot appear as table value) and nothing more. Boxing int for priority works fine.

Usage: https://gist.github.com/sergeyshaykhullin/bca8964c0ebbd5a8737a559bcb0287e3

If English isn't your first language, don't worry about it and try to
communicate the problem you are trying to solve to the best of your abilities.
As long as we can understand the intent, it's all good.

Types of Changes

  • Bugfix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • (Possible) Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (correction or otherwise)
  • Cosmetics (whitespace, appearance)

Checklist

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • All tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in related repositories

Further Comments

There are possible breaking changes, f.e. new version writes 'B', but old version doesnt know about it and throws SyntaxError

Docs https://www.rabbitmq.com/priority.html has
For 'x-max-priority' - This argument should be a positive integer between 1 and 255
For x-priority - The message priority field is defined as an unsigned byte, so in practice priorities should be between 0 and 255.
IBasicProperties has byte priority
So maybe it can help someone in future

case 'A':
value = ReadArray(reader);
break;
case 'B':
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading

WriteOctet(writer, (byte)'A');
WriteArray(writer, val);
break;
case byte val:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing

break;
default:
throw new WireFormattingException(
$"Value of type '{value.GetType().Name}' cannot appear as table value",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some exception details

@michaelklishin
Copy link
Member

Thank you for your ongoing pull requests!

It's not clear what's in scope for this PR. Adding some tests would help.

Please make sure you have read the AMQP 0-9-1 Errata document.

@sergeyshaykhullin
Copy link
Contributor Author

Yes, i got 'B' for byte from this document

@michaelklishin michaelklishin merged commit c343098 into rabbitmq:master Mar 20, 2019
@michaelklishin
Copy link
Member

Thank you. I will cherry-pick to 5.x..

michaelklishin added a commit that referenced this pull request Mar 20, 2019
Byte conversion support

(cherry picked from commit c343098)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants