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

Handle prefetchCount > max Short value #338

Open
Daenyth opened this issue Mar 31, 2020 · 3 comments
Open

Handle prefetchCount > max Short value #338

Daenyth opened this issue Mar 31, 2020 · 3 comments

Comments

@Daenyth
Copy link
Collaborator

Daenyth commented Mar 31, 2020

The AMQP spec says that prefetchCount is a short (16-bit) value. Despite this, the java amqp-client accents an int parameter. The int then has its MSB stripped off, and the remainder is reinterpreted as a short.

For example, if you supply a prefetch of 1_000_000, that gets interpreted as a prefetchCount of 16960

0b11110100001001000000 // 1_000_000
-----0b100001001000000 // 16_960

I have two proposals:

  • fs2-rabbit can change its own prefetchCount parameter of BasicQos to be a Short instead of an Int. Then invalid values simply can't be passed. Comments can direct the user about what to do It's actually interpreted as an unsigned short, so we don't have an out of the box type for it.
  • (binary compatible) fs2-rabbit can log an error when there's an attempt to basicConsume with prefetchCount > (2^16-1). We can also optionally "round" the requested count down to exactly (2^16-1)
@drobert
Copy link
Contributor

drobert commented Mar 31, 2020

I've opened an issue upstream as well: rabbitmq/rabbitmq-java-client#640

@drobert
Copy link
Contributor

drobert commented Mar 31, 2020

Following up, it seems the technical limit is a logical "unsigned short" (see rabbitmq/rabbitmq-java-client#640 (comment) ). So @Daenyth is correct with 2^16, or 65535

@stale
Copy link

stale bot commented Jul 30, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 30, 2020
@Daenyth Daenyth added pinned and removed wontfix labels Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants