[rabbitmq-discuss] Routing Key issue

lngphp lngphp at gmail.com
Sun Oct 2 06:06:43 BST 2011


Resolved - I needed to have different Queues...

On Oct 1, 3:34 pm, lngphp <lng... at gmail.com> wrote:
> Hi
>
> I'm trying to figure out how RabbitMQ/php-amqplib work and have issue
> with Routing Keys.
> Two messages are sent to 'Queue' queue using Routing Keys:
> 'server1.info' and 'server1.error':
>
> $server = 1;
> $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
> $channel = $conn->channel();
> $channel->exchange_declare(XCHANGE_NAME, 'topic', false, true, false);
> $msg = new AMQPMessage('Server '.$server.' INFO'
> , array('content_type' => 'text/plain'));
> $channel->basic_publish($msg, XCHANGE_NAME
> , 'server'.$server.'.info');
> $msg = new AMQPMessage('Server '.$server.' ERROR'
> , array('content_type' => 'text/plain'));
> $channel->basic_publish($msg, XCHANGE_NAME
> , 'server'.$server.'.error');
>
> On the other end, I use '#.error' in consumer-error.php and '#.info'
> in consumer-info.php, but both messages are appeared if I run any of
> the consumers:
>
> $conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
> $channel = $conn->channel();
> $channel->exchange_declare(XCHANGE_NAME, 'topic', false, true, false);
> $channel->queue_declare(QUEUE_NAME, false, true, false, false);
> $channel->queue_bind(QUEUE_NAME, XCHANGE_NAME, '#.info');
> function process_message($msg) {
> echo $msg->body."\n";
> $msg->delivery_info['channel']->
> basic_ack($msg->delivery_info['delivery_tag']);}
>
> $channel->basic_consume(QUEUE_NAME, 'consumer', false, false, false,
> false, 'process_message');
> while(count($channel->callbacks)) {
> $channel->wait();
>
> }
>
> I'm expecting the separation by this key, but it doesn't happen. What
> am I doing wrong?
>
> Regards,
> Roman
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-disc... at lists.rabbitmq.comhttps://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss


More information about the rabbitmq-discuss mailing list