Announcement Announcement Module
Collapse
No announcement yet.
Asynchronous RPC call Implementation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Asynchronous RPC call Implementation

    Hello, I am a new developer and have questions about spring AMQP when it comes to asynchronous RPC.

    Currently I can define a reply-queue for the rabbit template. When I do this, it seems I must also create a rabbit reply listener, like so:
    Code:
    <rabbit:template id="amqpTemplate" 
    	reply-timeout="${amqp.replyTimeout}" 
    	connection-factory="connectionFactory"
    	reply-queue="amqpReplyQueue" >
    	<rabbit:reply-listener id="rabbitReplyListener"
    		acknowledge="auto"
    		concurrency="${amqp.listener.concurrency}"
    		prefetch="${amqp.listener.prefetch}"
    		transaction-size="${amqp.listener.transactionSize}" />
    </rabbit:template>
    How can I specify what listener is called? I need to do some business processing on the callback, before it's removed from the broker reply queue.

    Alternatively, I've tried to let the reply queue be automatically generated and then specify a listener container with a listener, but this requires me to specify the queue:
    Code:
    <rabbit:listener-container  
    	acknowledge="auto"
    	concurrency="${amqp.listener.concurrency}"
    	connection-factory="connectionFactory"
    	prefetch="${amqp.listener.prefetch}"
    	transaction-size="${amqp.listener.transactionSize}" >
    	<rabbit:listener 
    		ref="myCallbackListener"
    		method="handleCallback" 
    		queues="${amqp.replyQueue}"/>
    </rabbit:listener-container>
    What is the correct way to specify both the reply-to queue and the listener I write?

    Also, how can I set the acknowledgement mode with a property placeholder? It won't let me type anything other than auto, manual, or none.

    I really appreciate any assistance. Thanks guys!

  • #2
    Well, the namespace is set up so that the template becomes the listener.

    You should be able to set the reply-queue on the template and use an external listener, as long as the RabbitTemplate onMessage() method is called after you've manipulated the reply - but it's important to retain the message properties used by the template to correlate the reply to the request. However, you must use a fixed reply-queue on the template when using a container, and the parser doesn't allow a reply-queue without a reply-listener.

    Unfortunately, the schema doesn't currently allow a placeholder for the acknowledge attribute.

    For both these reasons, you'll have to fall back to using <bean/> syntax to define the RabbitTemplate and SimpleMessageListenerContainer, which should work for you.

    Feel free to open an Improvement JIRA for the acknowledge attribute. https://jira.springsource.org/browse/AMQP

    I am not so sure we should relax the restrictions on the reply container - we'd have to be very careful to explain the limitations in the documentation.

    Comment

    Working...
    X