mardi 30 juillet 2019

How to add data in queue(RabbitMQ) in Laravel?

I gonna use RabbitMQ as broker message in Laravel. Documentation says to use default queues, just configure type of broker (Database, RabbitMQ .etc).

To use queues in Laravel I should implement interface ShouldQueue:

class ProcessPodcast implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $podcast;

    public function __construct(Podcast $podcast)
    {
        $this->podcast = $podcast;
    }

    public function handle(AudioProcessor $processor)
    {
        // Process uploaded podcast...
    }
}

Then to send message like:

  ProcessPodcast::dispatch($podcast);

Could I leave method public function handle() as empty?

Because I want just to add message. There is another service, that listens RabbitMQ queue.

My question is, how to add a new message in RabbitMQ under Laravel to specific exchange and queue?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire