
Originally Posted by
Dave Syer
It's not really the broker that is responsible for interpreting the reply-to header, it's the consumer (which in your case is Erlang, and very well might be in the same VM as the broker, but it isn't the broker). The binding uri format that we use by default is a convention that many AMQP clients adopt, but I don't think it's part of the spec. You have two choices: change the consumer, or change the producer. I have no idea how you would change the consumer, but that's just my ignorance of Erlang. The producer would need to manipulate the reply-to header before the message is sent. There should be plenty of scope for that in the RabbitTemplate.
Agreed. In the scope of rpc, placing producer reply-to convention cognizance on consumers is a bad idea and introduces coupling. Why anything other than a simple routing key and the use of the default exchange would be used for rpc responses seems counterintutive to the spec (and certainly a violation of "keep it simple").
To reiterate, you are acknowledging that since this is the RabbitTemplate, the proper solution is to provide a reply-to value that RabbitMQ itself has adopted, thus the RabbitTemplate should remove the bindig uri information and simply provide the queue's name? The RabbitMQ code is properly responding to the default exchange, providing the given reply-to attribute as the routing key.
thanks!
Ps: here's the hack to enable the amqp_rpc_server Erlang module to work (for anyone reading this, this introduces a coupling to rpc producer; said differently, don't do this):
Code:
handle_info({#'basic.deliver'{delivery_tag = DeliveryTag},
#amqp_msg{props = Props, payload = Payload}},
State = #state{handler = Fun, channel = Channel}) ->
#'P_basic'{correlation_id = CorrelationId,
reply_to = Q} = Props,
<<"direct:///", RoutingKey/binary>> = Q,
Response = Fun(Payload),
Properties = #'P_basic'{correlation_id = CorrelationId},
Publish = #'basic.publish'{exchange = <<>>,
routing_key = RoutingKey,
mandatory = true},
amqp_channel:call(Channel, Publish, #amqp_msg{props = Properties,
payload = Response}),
amqp_channel:call(Channel, #'basic.ack'{delivery_tag = DeliveryTag}),
{noreply, State}.