Closed abublihi closed 5 months ago
Hey @abublihi I assume your data is produced by the web application serving behind web servers. If that's the case then I'd say that no. To my knowledge, It's not possible even with any available package. Because that's the nature of PHP. Your script gets executed for each request and after the request is served those connections (read variables) get erased from the memory.
What you can do is keep a variable alive throughout the lifecycle of the request (just like the laravel container does) and if you publish multiple messages, that connection should be alive for that request will use the same connection.
Or if you're using Laravel, I'd suggest you use https://github.com/ssi-anik/laravel-amqp
Hope this answers your question.
Thank you very much, that answers my question.
After some searching i have found that it's possible to make the connection alive when using Laravel Octane, as of https://github.com/vyuldashev/laravel-queue-rabbitmq/issues/460 you can see that itls possible to make the connection a live,,
So can we replicate that using this package when using Laravel Octane?
@ssi-anik
Hello @abublihi Laravel Octane works differently than traditional PHP applications.
I haven't used Octane yet and am unsure if the package will work with Octane. None of the consumers of the package had informed me before about it. Could you give it a try? I will have to do some research. But I won't be able to manage time for the next couple of weeks.
Not a problem, i will try my best to contribute on this regard.
thank you @ssi-anik
@ssi-anik is it possible to keep the connection alive,,
Currently, for each time we need to publish a new message to RabittMQ we need to make a new connection, it's very slow, is it possible to make the connection as a keepalive?