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

The best way for non-blocking publishing #121

Open
gegorov2030 opened this issue Dec 29, 2021 · 1 comment
Open

The best way for non-blocking publishing #121

gegorov2030 opened this issue Dec 29, 2021 · 1 comment

Comments

@gegorov2030
Copy link

Can you suggest the best way to forward messages from stdin to rabbitmq. Unfortunately, in the example below, stdin is blocked for a significant amount of time.

<?php
declare(strict_types=1);

use Bunny\Client;

require_once __DIR__ . '/vendor/autoload.php';

$channel = (new Client())->connect()->channel();

while (($record = fgetcsv(STDIN, 4096, ',')) !== false) {
    $channel->publish(json_encode($record), [], '', $config['queue']['name']);
}

Logically, I need to use an asynchronous client but did not find a similar example.

@WyriHaximus
Copy link
Collaborator

Maybe https://github.com/clue/reactphp-stdio can help with this? Alternatively this package and example might be even better for your use case: https://github.com/clue/reactphp-csv#usage

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

2 participants