PHP code example of cmdrsharp / amqp-route-messenger
1. Go to this page and download the library: Download cmdrsharp/amqp-route-messenger library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use CmdrSharp\AmqpRouteMessenger\Client;
/**
* @var ClientInterface
*/
protected $client;
public function __construct()
{
$this->client = new Client();
}
$instance = $this->client->declareExchange('messages')->publish('correlation_id', 'your message');
// Don't forget to close the channel and connection when done!
$instance->closeChannel()->closeConnection();
$instance = $this->client->declareExchange('messages')
->declareQueue()
->bindQueue('correlation_id');
// Note: Reading does freeze the thread until it receives a message.
$message = $instance->read();
// Again, don't forget to close the channel and connection!
$instance->closeChannel()->closeConnection();