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

Call to undefined method Basis\Nats\Consumer\Consumer::getQueue() #101

Open
ljfreelancer88 opened this issue Nov 22, 2024 · 0 comments
Open

Comments

@ljfreelancer88
Copy link
Contributor

Hi, I got undefined method when using the 1 & 2 approaches below.

Uncaught Error: Call to undefined method Basis\Nats\Consumer\Consumer::getQueue() 
# Approach 1
$queue = $post_notifier_consumer->setBatching(50)->create()->getQueue();
$messages = $queue->setTimeout(1)->fetchAll(100);

$recipients = [];
foreach ($messages as $message) {
    $recipients[] = (string) $message->payload;
}
var_dump($recipients);
# Approach 2
$post_notifier_consumer->create();
$queue = $post_notifier_consumer->getQueue();
while ($msg = $queue->next()) {
    $postNotification = json_decode($msg, true);
    var_dump($postNotification);
    /*
    if (someConitionToStop) {
        $client->unsubscribe($queue);
        break;
    }
    */
}

These are both fine

# Approach 3
$post_notifier_consumer->handle(function ($msg) {
    var_dump($msg);
});
# Approach 4
$post_notifier_consumer
    ->setBatching(2) // how many messages would be requested from nats stream
    ->setIterations(3) // how many times message request should be sent
    ->handle(function ($msg) {
        var_dump($msg);
    });
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