Skip to content

Thoughts about a v2? #114

@byrnedo

Description

@byrnedo

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions