You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
subscribe to a given channel
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?
The text was updated successfully, but these errors were encountered:
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 processn
messages on a given sub then I can't do that. I can only processn
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
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 thewait(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?
The text was updated successfully, but these errors were encountered: