majek / puka

Puka - the opinionated RabbitMQ client
https://github.com/majek/puka
Other
182 stars 34 forks source link

Implement a way for doing "Direct reply-to" #65

Open fishtek opened 9 years ago

fishtek commented 9 years ago

Hello,

In RabbitMQ v3.4.0 they added a method for doing fast RPC called "Direct reply-to"

For users supposedly the server side of the RPC can remain the same (as long as it is publishing to the default exchange), the "magic" happens on the client side. However w/ the current version of Puka v0.0.7 I can not get this to work.

I have tried various versions of the rpc client:

Leaving the rpc_client mostly the same and only doing the wait on the self.consume_promise causes the client to simply hang. If I do wait on the publish first then i get back an exception:

  File "/usr/local/lib/python2.7/dist-packages/puka/connection.py", line 329, in wait
    raise_errors=raise_errors)
  File "/usr/local/lib/python2.7/dist-packages/puka/promise.py", line 35, in run_callback
    return self._promises[number].run_callback(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/puka/promise.py", line 135, in run_callback
    raise result.exception
puka.spec_exceptions.PreconditionFailed: {'class_id': 60, 'method_id': 40, 'reply_code': 406, 'reply_text': 'PRECONDITION_FAILED - fast reply consumer does not exist'}

I suspect it is because under the hood puka uses seperate channels for publishing and consuming? Perhaps this feature of RabbitMQ requires the same channel to be used when doing this type of RPC? If that is the case I wonder if there is any easy way to extend or modify Puka to support it?