[rabbitmq-discuss] Pub/sub with expiring reply queue

Richard Marr richard.marr at gmail.com
Wed Oct 29 11:10:30 GMT 2008


Ben,

> It's quite hard to tell without actually seeing the code :-)

Yep. I was naively hoping it'd be an obvious n00b question that you'd
know right off the bat  :o)

The demo I've built delivers each message to two queues, but is
currently syncronous so only waits for the first response. My debug
output tells me that both subscribers (one per queue) get the message
body intact, but the replyTo property is null, even though the reply
queue name generated in the client looks valid. I put debug just
before the RpcClient.publish() call in the RpcClient.primitiveCall()
method and it lookeds fine.

Should the properties object be passed through transparently?



// The client code looks like this:

String exchangeName = "searchExchange";
String routingKey = "search.replica.1";
int ticket = _channel.accessRequest( _realm );
	
RpcClient rpc = new RpcClient( _channel, ticket, exchangeName, routingKey );
byte[] results = rpc.primitiveCall( query.getBytes() );



// And the server code looks like this:

int ticket = _channel.accessRequest( _realm );

String exchangeName = "searchExchange";
String queueName = "search.partition."+_partitionCode+".replica." +
_replicaCode;
String bindingKey = "search.replica." + _replicaCode;

_channel.exchangeDeclare(ticket, exchangeName, "direct");
_channel.queueDeclare(ticket, queueName);
_channel.queueBind(ticket, queueName, exchangeName, bindingKey );

RpcServer server = new RpcServer( _channel, ticket, queueName ){
	@Override
	public byte[] handleCall(QueueingConsumer.Delivery request,
AMQP.BasicProperties replyProperties)
	{
		return _index.search( request.getBody() );
	}
};
ShutdownSignalException e = server.mainloop();




More information about the rabbitmq-discuss mailing list