Results 1 to 3 of 3

Thread: Amqp Outbound Channel Adapter Dynamically changing routing key?

Hybrid View

  1. #1

    Question Amqp Outbound Channel Adapter Dynamically changing routing key?

    Hi,

    I'm using SI and SI-AMQP to send message to Rabbit MQ over SI Message Channels. So in my MessageProducer class I will get a handle on a spring integration MessageChannel and use this to send SI messages to an amqp-outbound-channel-adapter. Now the issue I'm facing is when I want to use the amqp outbound channel but I want to provide a routing key dynamically and not at compile time.

    My first instinct was to drop back down to the level of the RabbitTemplate as I know this can be done from there. But the downside is I cannot send SI messages via the template, also I cannot specify mapping-headers="*" like I would in the amqp outbound channel adapter. Each request in the system causes one part of the system to dynamically generate queue's with specific routing keys on them based on a UUID and then events must be sent to this specific queue for that given request. At the end of that requests life cycle the queues are destroyed.

    My config is as shown below for producing messages

    Code:
    <bean id="rabbitTemplate" class="org.springframework.amqp.rabbit.core.RabbitTemplate" >
    		<constructor-arg name="connectionFactory" ref="connectionFactory" />
    		<property name="exchange" value="events.topic" />
    		<property name="routingKey" value="events.routing.key" />
    		<property name="queue" value="events" />
    	</bean>
    	
    	<int-amqp:outbound-channel-adapter
    		id="amqpOutboundChannelAdapter"
    		amqp-template="rabbitTemplate"	
    		exchange-name="events.topic"
    		mapped-request-headers="*"
    		routing-key="events.routing.key"
    		channel="outboundEventChannel"
    	/>
    	
    	<int:channel id="outboundEventChannel" />
    	
    	<bean id="eventsMessageProducer" class="com.idna.events.producer.EventsMessageProducer" >
    		<property name="outboundChannel" ref="outboundEventChannel" />
    	</bean>
    If anyone can even just point me in the right direction that would be great.

    Thanks!

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,844

    Default

    You can replace the 'routing-key' attribute with 'routing-key-expression'.

    Hope that helps.
    -Mark

  3. #3

    Cool

    Quote Originally Posted by Mark Fisher View Post
    You can replace the 'routing-key' attribute with 'routing-key-expression'.

    Hope that helps.
    -Mark
    Fantastic, much appreciated.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •