Clarification on directy reply-ro

703 views
Skip to first unread message

Bogdan Padalko

unread,
Apr 10, 2015, 8:30:16 AM4/10/15
to rabbitm...@googlegroups.com
Hi,

I working on https://github.com/pdezwart/php-amqp/issues/155 bug which is about "RabbitMQ's Direct reply-to" and I can't figure out whether I get something wrong in https://www.rabbitmq.com/direct-reply-to.html doc or something wrong with my local settings or there are other pitfal that ban me from making minimal example.

I do not provide php-amqp example while the whole fast-reply support is totatly broken in it and without some patches it will not work at all. Anyway, the whole direct reply-to idea is the same across all client libraries, so to demonstrate the issue, I tried php-amqplib by Alvaro Videla and write such example:

test-amqplib.php file:

<?php

require "vendor/autoload.php";

use PhpAmqpLib\Message\AMQPMessage;

$conn
= new \PhpAmqpLib\Connection\AMQPStreamConnection(
   
'localhost',
   
5672,
   
'guest',
   
'guest'
);
$channel
= $conn->channel();

// Establish connection, create a channel...
$callback_queue
= 'amq.rabbitmq.reply-to';

$response
= null;
$channel
->basic_consume($callback_queue, '', false, true, false, false, function (AMQPMessage $message) use (&$response) {
    echo $message
->body . PHP_EOL;
    $response
= true;
});

$msg
= new AMQPMessage('ping', [
   
'reply_to' => $callback_queue
]);

$channel
->basic_publish($msg, '');
while (!$response) {
    $channel
->wait();
}


and run

# composer require videlalvaro/php-amqplib
# php test-amqplib.php

and it doesn't output me anything, just handing and waiting for data on connection. At this point I'm a bit disappointed while I guess I folowed https://www.rabbitmq.com/direct-reply-to.html doc.

My environment (yupp, this is Vagrant box):

vagrant@vagrant-ubuntu-utopic-64 (php:5.6.4 -phpbrew):~/php-amqp$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 14.10
Release:    14.10
Codename:    utopic
vagrant@vagrant
-ubuntu-utopic-64 (php:5.6.4 -phpbrew):~/php-amqp$ php -v
PHP
5.6.4 (cli) (built: Jan 22 2015 02:06:06) (DEBUG)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
   
with Xdebug v2.2.7, Copyright (c) 2002-2015, by Derick Rethans
vagrant@vagrant
-ubuntu-utopic-64 (php:5.6.4 -phpbrew):~/php-amqp$ sudo rabbitmqctl status
Status of node 'rabbit@vagrant-ubuntu-utopic-64' ...
[{pid,23071},
 
{running_applications,
     
[{rabbitmq_management,"RabbitMQ Management Console","3.5.1"},
     
{rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.5.1"},
     
{webmachine,"webmachine","1.10.3-rmq3.5.1-gite9359c7"},
     
{mochiweb,"MochiMedia Web Server","2.7.0-rmq3.5.1-git680dba8"},
     
{rabbitmq_management_agent,"RabbitMQ Management Agent","3.5.1"},
     
{rabbit,"RabbitMQ","3.5.1"},
     
{os_mon,"CPO  CXC 138 46","2.2.15"},
     
{inets,"INETS  CXC 138 49","5.10.2"},
     
{amqp_client,"RabbitMQ AMQP Client","3.5.1"},
     
{xmerl,"XML parser","1.3.7"},
     
{mnesia,"MNESIA  CXC 138 12","4.12.1"},
     
{sasl,"SASL  CXC 138 11","2.4"},
     
{stdlib,"ERTS  CXC 138 10","2.1"},
     
{kernel,"ERTS  CXC 138 10","3.0.1"}]},
 
{os,{unix,linux}},
 
{erlang_version,
     
"Erlang/OTP 17 [erts-6.1] [source] [64-bit] [async-threads:30] [kernel-poll:true]\n"},
 
{memory,
     
[{total,41857968},
     
{connection_readers,0},
     
{connection_writers,0},
     
{connection_channels,0},
     
{connection_other,5264},
     
{queue_procs,1186248},
     
{queue_slave_procs,0},
     
{plugins,556032},
     
{other_proc,13241680},
     
{mnesia,256712},
     
{mgmt_db,725672},
     
{msg_index,163304},
     
{other_ets,1205336},
     
{binary,69816},
     
{code,20039855},
     
{atom,703377},
     
{other_system,3704672}]},
 
{alarms,[]},
 
{listeners,[{clustering,25672,"::"},{amqp,5672,"::"}]},
 
{vm_memory_high_watermark,0.4},
 
{vm_memory_limit,839496499},
 
{disk_free_limit,50000000},
 
{disk_free,37957558272},
 
{file_descriptors,
     
[{total_limit,924},{total_used,3},{sockets_limit,829},{sockets_used,1}]},
 
{processes,[{limit,1048576},{used,315}]},
 
{run_queue,0},
 
{uptime,5470}]








Michael Klishin

unread,
Apr 10, 2015, 8:49:09 AM4/10/15
to rabbitm...@googlegroups.com, Bogdan Padalko
On 10 April 2015 at 15:30:19, Bogdan Padalko (zaq17...@gmail.com) wrote:
> I working on https://github.com/pdezwart/php-amqp/issues/155
> bug which is about "RabbitMQ's Direct reply-to" and I can't figure
> out whether I get something wrong in https://www.rabbitmq.com/direct-reply-to.html
> doc or something wrong with my local settings or there are other
> pitfal that ban me from making minimal example.

Note that your example seems to only include the "send half" of request/reply — a server
reply and a client consuming from amq.rabbitmq.reply-to.

Compare this to Direct Reply-to tests which do both request and reply:
https://github.com/rabbitmq/rabbitmq-java-client/blob/master/test/src/com/rabbitmq/client/test/functional/DirectReplyTo.java

The Use paragraph on [1] mentions that

«The RPC server will then see a reply-to property with a generated name…»

which suggests RabbitMQ has to generate that unique value. Which assumes there should be a [request/reply] client
request ;) 

1. http://www.rabbitmq.com/direct-reply-to.html
--
MK

Staff Software Engineer, Pivotal/RabbitMQ


Michael Klishin

unread,
Apr 10, 2015, 8:53:08 AM4/10/15
to rabbitm...@googlegroups.com, Bogdan Padalko
 On 10 April 2015 at 15:49:06, Michael Klishin (mkli...@pivotal.io) wrote:
> The Use paragraph on [1] mentions that
>
> «The RPC server will then see a reply-to property with a generated
> name…»
>
> which suggests RabbitMQ has to generate that unique value. Which
> assumes there should be a [request/reply] client
> request ;)

To give you an example of such value:

"amq.rabbitmq.reply-to.g2dkAA9yYWJiaXRAbWVyY3VyaW8AAAFJAAAAAAI=.41Feb1a6XK29NG5/qnF24w=="

Bogdan Padalko

unread,
Apr 10, 2015, 10:22:08 AM4/10/15
to rabbitm...@googlegroups.com, zaq17...@gmail.com


Note that your example seems to only include the "send half" of request/reply — a server
reply and a client consuming from amq.rabbitmq.reply-to.

 
Yeah, I noted that my undersdanding was totally biased

It helped me a lot. Thanks. I miss that point that java client stays on bleeding edge (unlike .net and erlang one, right?).

The Use paragraph on [1] mentions that

«The RPC server will then see a reply-to property with a generated name…»

which suggests RabbitMQ has to generate that unique value. Which assumes there should be a [request/reply] client
request ;) 


The whole documentation is great, but at this part it is not clear, maybe it would be more obvious to write step-by-step workflow, say:
  1. Register amq.rabbitmq.reply-to consumer with no-ack flag. Later you will get here your response.
  2. Publish request message to your  queue (that one that will deal all your requests) with reply-to property set to amq.rabbitmq.reply-to.
  3. Then get (with basic.get) message from that queue and read reply-to property from it which should looks like  "amq.rabbitmq.reply-to.g2dkAB9yYWJiaXRAdmFncmFudC11YnVudHUtdXRvcGljLTY0AAAG6AAAAAAB.WHDm+gbSzz9WaF9n18WZwQ==" (without quotes).
  4. Declare passive queue with name set to reply-to property value from previous step. This one will not appear in management panel and is kinda virtual one. It will serve as a response transport.
  5. Publish reply to this queue. Now your consumer (that on from step 1) will get result.
  6. Note, that normally request and response activity happens separately and at least on different channels (which really makes sense), so trying to run all that on one channel will not work and is not wise act at all.
 

Michael Klishin

unread,
Apr 10, 2015, 11:13:20 AM4/10/15
to rabbitm...@googlegroups.com, Bogdan Padalko
On 10 April 2015 at 17:22:09, Bogdan Padalko (zaq17...@gmail.com) wrote:
> It helped me a lot. Thanks. I miss that point that java client
> stays on bleeding edge (unlike .net and erlang one, right?).

Java client test suite includes broker tests. We try to keep Java and .NET clients feature complete (at least now that .NET
has caught up with the 3.5.0 release). 

Michael Klishin

unread,
Apr 10, 2015, 11:14:16 AM4/10/15
to rabbitm...@googlegroups.com, Bogdan Padalko
On 10 April 2015 at 17:22:09, Bogdan Padalko (zaq17...@gmail.com) wrote:
> The whole documentation is great, but at this part it is not clear,
> maybe it would be more obvious to write step-by-step workflow,
> say:
> Register amq.rabbitmq.reply-to consumer with no-ack flag.
> Later you will get here your response.
> Publish request message to your queue (that one that will deal
> all your requests) with reply-to property set to amq.rabbitmq.reply-to.
> Then get (with basic.get) message from that queue and read reply-to
> property from it which should looks like "amq.rabbitmq.reply-to.g2dkAB9yYWJiaXRAdmFncmFudC11YnVudHUtdXRvcGljLTY0AAAG6AAAAAAB.WHDm+gbSzz9WaF9n18WZwQ=="
> (without quotes).
> Declare passive queue with name set to reply-to property value
> from previous step. This one will not appear in management panel
> and is kinda virtual one. It will serve as a response transport.
> Publish reply to this queue. Now your consumer (that on from step
> 1) will get result.
> Note, that normally request and response activity happens separately
> and at least on different channels (which really makes sense),
> so trying to run all that on one channel will not work and is not
> wise act at all.

I agree, we will review that guide.

We also are working on open sourcing our documentation site so others can help us — our team is tiny. 

Bogdan Padalko

unread,
Apr 10, 2015, 12:46:42 PM4/10/15
to rabbitm...@googlegroups.com, zaq17...@gmail.com

I agree, we will review that guide.

We also are working on open sourcing our documentation site so others can help us — our team is tiny. 

I try to keep eye on RabbitMQ project, so I would love to participate in it. You are doing great job.
 
Reply all
Reply to author
Forward
0 new messages