[rabbitmq-discuss] Select Connection RPC

Gonzalo Fernandez dvittomc at gmail.com
Wed Nov 21 15:23:02 GMT 2012


Yep, I have been trying with that doc but I can't make it work.

RPC_SERVER is working good.
My problem comes with the RPC_CLIENT.

I am still trying, but i can't figure it out...

*#!/usr/bin/env python*
*import pika*
*import uuid*
*
*
*class FibonacciRpcClient(object):*
* def __init__(self):*
* # self.connection = pika.BlockingConnection(pika.ConnectionParameters(*
* # host='localhost'))*
* print 'init---'*
*
*
* self.parameters = pika.ConnectionParameters(host='localhost')*
* print 'self.parameters =',self.parameters*
* # self.connection = pika.SelectConnection(parameters, on_connected)*
* self.connection = pika.SelectConnection(self.parameters)*
* print 'self.connection =',self.connection*
*
*
* # self.channel = self.connection.channel(self.on_channel_open)*
* *
* # Step #3*
* def on_channel_open(self,new_channel):*
* """Called when our channel has opened"""*
* # self.channel = new_channel*
* print 'on_channel_open...'*
* result = self.channel.queue_declare(exclusive=True)*
* print 'result =',result*
* self.callback_queue = result.method.queue*
*
*
* self.channel.basic_consume(self.on_response, no_ack=True,*
*   queue=self.callback_queue)*
*
*
* def open_connection(self):*
* print 'open_connection'*
* self.channel = self.connection.channel(self.on_channel_open)*
* print 'self.channel =',self.channel*
*
*
*
*
* def on_response(self, ch, method, props, body):*
* if self.corr_id == props.correlation_id:*
* self.response = body*
*
*
* def call(self, n):*
* self.response = None*
* self.corr_id = str(uuid.uuid4())*
* self.channel.basic_publish(exchange='',*
*   routing_key='rpc_queue',*
*   properties=pika.BasicProperties(*
* reply_to = self.callback_queue,*
* correlation_id = self.corr_id,*
* ),*
*   body=str(n))*
* while self.response is None:*
* self.connection.process_data_events()*
* return int(self.response)*
*
*
*fibonacci_rpc = FibonacciRpcClient()*
*print 'FibonacciRpcClient created'*
*fibonacci_rpc.open_connection()*

I never get to see the *RED *prints... :(
I see all *GREEN *prints

Until I get this right I can't start with the ioloop.... correct?

Thanks Gavin.



2012/11/21 Gavin M. Roy <gmr at meetme.com>

> You are correct, SelectConnection is an async adapter. Check out
>
> http://pika.readthedocs.org/en/latest/connecting.html
>
> And see if it helps.
>
> Regards,
>
> Gavin
>
> On Wed, Nov 21, 2012 at 7:14 AM, Gonzalo Fernandez <dvittomc at gmail.com>wrote:
>
>> Hi!
>>
>> I have been working with RabbitMQ for over 6 months now I have just
>> recently found a new Connection Type.
>>
>> Before, I only used BlockingConnection. Now I found SelectConnection and
>> I think it fits better for me.
>> Async right?
>>
>> Anyway, I am trying to make a small RPC example such as the one on the
>> tutorial but I am kind of stucked.
>>
>> I could use some help if you don't mind.
>>
>> I am trying to understand the ioloop.start() and how does a queue consume
>> its elements.
>>
>> Everything is different (or it looks like it) with this form of
>> connection.
>>
>> Any suggestions? Am I making it harder that it really is?
>>
>> I am a little ashamed of myself, but I can't figure it out.
>>
>> Thanks in advance.
>>
>> patpat ---
>>
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>>
>>
>
>
> --
>
> Gavin M. Roy
> Chief Technology Officer
>
>  <http://www.meetme.com/>
> 100 Union Square Drive
> New Hope, PA 18938
> p. +1.215.862.1162 x263
> f. +1.215.862.0465
>
> <https://www.facebook.com/pages/MeetMe/21931227129>   <https://twitter.com/meetme>
>     <http://www.youtube.com/user/MeetMeVideos>
>
> The public market leader in social discovery. (NYSE MKT: MEET)
>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20121121/b4aa929a/attachment.htm>


More information about the rabbitmq-discuss mailing list