Announcement Announcement Module
Collapse
No announcement yet.
Multiple clients with unique queue names Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple clients with unique queue names

    RabbitMQ: 2.7.1
    Spring Integration: 2.2.0.M1
    Spring AMQP: 1.1.0.RELEASE

    I have numerous desktop clients that I wish to connect to a RabbitMQ server to send commands to server processes. I also want the clients to be able to subscribe to queues to receive messages coming from other clients or server processes. My understanding of AMQP is that I want to declare a fanout exchange and process messages to that exchange with a routing key. The clients would need to declare a queue and bind it to that exchange and routing key.

    This much I get. And I understand that while I say "server" and "client" that both include being a producer and consumer of messages.

    Now for the client to subscribe to the fanout exchange it needs to create a queue and bind it with a routing key. Since it is the same client desktop application on many desktops then I must have a unique name for the queue. I am having some issues with the configuration to connect an AmqpInboundGateway with an UniquelyNamedQueue.

    Here is the definition for my queue:
    Code:
    	<rabbit:queue id="randomQueue"
    				  durable="false"
    				  auto-delete="true"
    				  exclusive="true" />
    The queue is created and can be viewed using rabbitmqctl. Here are the logs from the running application:
    Code:
    2012-05-26 23:29:24 - RabbitAdmin.initialize(293) | Auto-declaring a non-durable Queue (db62a474-3347-4b25-afc8-bdb146b92e42). It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
    2012-05-26 23:29:24 - RabbitAdmin.initialize(298) | Auto-declaring an auto-delete Queue (db62a474-3347-4b25-afc8-bdb146b92e42). It will be deleted by the broker if not in use, and all messages will be lost.  Redeclared when the connection is closed and reopened.
    2012-05-26 23:29:24 - RabbitAdmin.initialize(303) | Auto-declaring an exclusive Queue (db62a474-3347-4b25-afc8-bdb146b92e42). It cannot be accessed by consumers on another connection, and will be redeclared if the connection is reopened.
    The problem is how do I now associate this uniquely named queue to an inbound gateway? The gateway requires that I specify queue names. However I don't know the queue name. I tried to reference it using the Spring bean ID but it errors stating that the queue "randomQueue" doesn't exist. I even tried using EL but that was still passed directly as a String and to find it as a queue:
    Code:
    	<int-amqp:inbound-gateway id="newsGateway"
    							  request-channel="newsQueryInput"
    							  reply-channel="newsQueryOutput"
    							  queue-names="${randomQueue.name}"
    							  connection-factory="connectionFactory"
    							  message-converter="jsonMessageConverter"
    							  error-channel="errorChannel"
    							  advice-chain="retryInterceptor" />
    Any assistance or direction would be greatly appreciated.

  • #2
    After I posted my message 10 minutes ago I continued to look at the issue. Instead of EL (or really property placeholder syntax) I tried SpEL and it worked perfectly:
    Code:
    	<int-amqp:inbound-gateway id="newsGateway"
    		  request-channel="newsQueryInput"
    		  reply-channel="newsQueryOutput"
    		  queue-names="#{randomQueue.name}"
    		  connection-factory="connectionFactory"
    		  message-converter="jsonMessageConverter"
    		  error-channel="errorChannel"
    		  advice-chain="retryInterceptor" />
    So it is posted here for others to learn.

    Comment

    Working...
    X