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

Thoughts about a v2? #114

Open
byrnedo opened this issue Nov 18, 2017 · 0 comments
Open

Thoughts about a v2? #114

byrnedo opened this issue Nov 18, 2017 · 0 comments

Comments

@byrnedo
Copy link
Contributor

byrnedo commented Nov 18, 2017

Hi @repejota ,

I've been getting https://github.com/byrnedo/php-nats-streaming up and running and have come across a few things that I think could be improved in phpnats.
First off, I nabbed some of your code from phpnats (I'm using your nats client fully though) so thanks and I've given you a shout out on the readme :)

The main thing is the $con->wait(n). The fact that if I wanted to process n messages on a given sub then I can't do that. I can only process n random messages on any sub.

This hits badly with the nats-streaming client since there's a bunch of requests in the protocol (especially the acks sent back for each publish).

example of the problem in nats-streaming

  1. subscribe to a given channel
  2. immediately after publish n messages to the channel

In the above scenario, the published message is received in the sub before the 'ack' for the publish is sent from the server. So I can't do a phpnats request for those since the wait(1) actually processes the subscriptions cb instead of the ack.

I've changed the wait to be on the sub alone, and basically the n is the number of messages received for that sub. I process other messages though. See here in the code.

I had a look around and see that php-amqplib does the same kind of thing, except saves the 'other' subjects messages received when waiting for later, and if another sub's wait is called, it checks the cached message list first.

So, my suggestion is to make subscribe return an object that can wait.

Any thoughts?

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

No branches or pull requests

1 participant