Announcement Announcement Module
Collapse
No announcement yet.
Amqp Outbound Channel Adapter Dynamically changing routing key? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    You can replace the 'routing-key' attribute with 'routing-key-expression'.

    Hope that helps.
    -Mark

    Comment


    • #3
      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.

      Comment

      Working...
      X