[rabbitmq-discuss] php talking to ruby
Pieter de Zwart
pdezwart at rubiconproject.com
Wed Jan 19 16:41:14 GMT 2011
It unfortunately sounds like the PHP client is not conforming to the spec,
or that the configuration isnt working. I am not familiar with the default
routing mechanism (adding to my to do list now,) but I see no reason why we
cant shoe horn your original code to work. First, you need to remove the
queue declaration from your PHP code:
// Create a connection
$cnn = new AMQPConnection();
$cnn->connect();
// Declare a new exchange
$ex = new AMQPExchange($cnn);
$ex->declare('direct1', AMQP_EX_TYPE_DIRECT);
// Publish a message to the exchange with a routing key
$ex->publish('message', 'routing.key');
The Ruby client should have already defined the queue and its binding on
which it will be listening. Give that a shot and let us know how it works
out.
me
On 1/19/11 6:10 AM, "Robin Wood" <robin at digininja.org> wrote:
> On 19 January 2011 13:39, Michael Klishin <michael.s.klishin at gmail.com> wrote:
>> Robin,
>> What happens here two of your apps declare queue with different attributes
>> because default values for
>> parameters like durability seems to differ between that php library and what
>> amqp gem uses.
>
> I was hoping that that was the problem rather than a bug in my code.
>
>> Since you only want to consume messages on the Ruby side and publish them on
>> the PHP side, you
>> have an option of only declaring one queue in your Ruby app and one exchange
>> in the PHP app. Then you
>> can use default exchange that routes messages to queues when routing key
>> matches queue name.
>> When queue is declared only in one place, differences in library defaults
>> won't get in the way. And, default exchange
>> was added to AMQP spec exactly for simple
>> cases like yours. This scenario is
>> described at http://www.rabbitmq.com/tutorial-one-python.html.
>> Hope this helps.
>
> I've had a look at the tutorial and from my original code I've removed
> the exchange line from the Ruby consumer script which I assume means
> it will go to the default one and changed the php exchange declare
> line to:
>
> $ex->declare('');
>
> but when I run it I get
>
> PHP Fatal error: Uncaught exception 'AMQPExchangeException' with
> message 'Server channel error: 403, message: ACCESS_REFUSED -
> operation not permitted on the default exchange' in
> /home/robin/comms/a.php:9
> Stack trace:
> #0 /home/robin/comms/a.php(9): AMQPExchange->declare('')
> #1 {main}
> thrown in /home/robin/comms/a.php on line 9
>
> If I change the empty string to default then I get the same
> PRECONDITION_FAILED as before. I've not added any authentication
> anywhere.
>
> I want this to be able to work both directions, php tell Ruby to do
> something then Ruby tell php when it is finished through a different
> message. Will this work with this setup once I get the actual code
> working?
>
> Robin
>
>>
>> 2011/1/19 Robin Wood <robin at digininja.org>
>>>
>>> When I run the php I get:
>>>
>>> PHP Fatal error: Uncaught exception 'AMQPQueueException' with message
>>> 'Server channel error: 406, message: PRECONDITION_FAILED - parameters
>>> for queue 'queue1' in vhost '/' not equivalent' in
>>> /home/robin/sched/a.php:13
>>> Stack trace:
>>> #0 /home/robin/sched/a.php(13): AMQPQueue->declare('queue1')
>>> #1 {main}
>>> thrown in /home/robin/sched/a.php on line 13
>>>
>>
>> --
>> MK
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
More information about the rabbitmq-discuss
mailing list