ricbra / rabbitmq-cli-consumer

Consume RabbitMQ messages into any cli program
MIT License
247 stars 49 forks source link

rabbitmq-cli-consumer with rpc #3

Closed satboy78 closed 8 years ago

satboy78 commented 9 years ago

Hi Richard, I’m trying to use your rabbitmq-cli-consumer with my symfony 2.3 application; my application uses (oldsound/rabbitmq) rpc, and I’m having some troubles working with your consumer, because my app doesn’t receive any message (I get AMQP timeout error) (maybe because I’ve to set a queue name in rabbitcli conf file, and in rpc configuration in symfony I don’t have a named queue?)

this is the error I get:

2015/03/02 14:45:53 Processing message… 2015/03/02 14:45:54 Failed. Check error log for details. 2015/03/02 14:45:54 Failed: [RuntimeException] Too many arguments. rabbitmq:rpc-server [-m|–messages[=”…”]] [-d|–debug[=”…”]] name 2015/03/02 14:45:54 Error: exit status 1

I’ve tried removing queue name in rabbit cli conf file, now the process is running but no message received/consumed; restoring queue name I get previous error (Too many arguments).

Do you think it's possible to make your client able to work even with rpc?

Thanks a lot.

Matteo

ricbra commented 9 years ago

At this moment RPC is not supported yet.

I haven't used RabbitMQ with RPC yet, so it's hard to say how difficult it is to implement this. When I have the time I'll look into it. Unfortunately I can't promise when that will be.

satboy78 commented 9 years ago

ok, thanks!

ricbra commented 9 years ago

I've been digging into this RPC thing and it seems to me it's just a property of the AMQP message. So it should be working.

Could you post your configuration file and also the RabbitMQ Symfony2 bundle configuration?

satboy78 commented 9 years ago

Hi Richard, thanks a lot for your answer.

This is the configuration of OldSoundRabbitMQBundle:

old_sound_rabbit_mq: connections: default: host: 'localhost' port: 5672 user: 'guest' password: 'guest' vhost: %rabbitmq_prefix%%locale% lazy: false rpc_clients: widget_render_client: connection: default expect_serialized_response: true rpc_servers: widget_render_server: connection: default callback: mybundle.widget.render_wrapper

And this is the configuration file:

[rabbitmq] host = localhost username = guest password = guest vhost=/it_IT port=5672 queue=itqueue compression=Off

[logs] error = /var/log/rabbitcli/error.log info = /var/log/rabbitcli/info.log

I think that the problem is the name of the queue: in parallel rpc we don't have a named queue, but we have an anonymous callback one (rabbit will create a unique name for the queue, and it will create a correlation_id which is set to a unique value for every request).

I took a look to this tutorial and, even if I'm not a go programmer, anyway I've changed a little bit your consumer:

(row 104) q, err = ch.QueueDeclare(cfg.RabbitMq.Queue, true, false, false, false, nil) (row 136) Queue: q.Name,

but it doesn't work because I need correlation_id... and I'm stuck here, trying to figure out how to get this value.

Hope we can find a solution :)

Have a great day! Matteo

ricbra commented 9 years ago

In order to handle RCP some things need to be changed to the Go consumer. I found an example implementation here: https://github.com/hirolovesbeer/golang-memo/blob/master/rabbitmq-rpc-echo-client.go

I'll add it to the todo list :)

satboy78 commented 9 years ago

ok, thanks a lot!

ricbra commented 8 years ago

RPC is added in v2 branch. Keep an eye on the PR, I'll be closing this issue for now.