I want to know ... how can I send a file to the rabbitmq queue from php. I went through many examples, most of them did not work. Below is an example of a consumer who is close to work. Below is the publisher.php file
<?php
require_once('../php-amqplib/amqp.inc');
include('../config.php');
$conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
$channel = $conn->channel();
$channel->exchange_declare('upload-pictures','direct', false, true, false);
$metadata = json_encode(array(
'image_id' => $argv[1],
'user_id' => $argv[2],
'image_path' => $argv[3]
));
$msg = new AMQPMessage($metadata, array('content_type' => 'text/plain','delivery_mode' => 2));
$channel->basic_publish($msg, 'upload-pictures');
$channel->close();
$conn->close();
?>
consumer.php
<?php
require_once('../php-amqplib/amqp.inc');
include('../config.php');
$conn = new AMQPConnection(HOST, PORT, USER, PASS,VHOST);
$channel = $conn->channel();
$queue = 'add-points';
$consumer_tag = 'consumer';
$channel->exchange_declare('upload-pictures','direct', false, true, false);
$channel->queue_declare('add-points',false, true, false, false);
$channel->queue_bind('add-points', 'upload-pictures');
$consumer = function($msg){};
$channel->basic_consume($queue,$consumer_tag,false,false,false,false,$consumer);
?>
according to the example given in the rabbitmq manual, I need to start the user (php consumer.php) first in one terminal and the publisher (php publisher.php 1 2 file / path.png) in another terminal, I get the message “Add points to user: 2 "in the consumer terminal. I do not receive this message at all. can you suggest where i'm not mistaken