Announcement Announcement Module
Collapse
No announcement yet.
Interceptor on message driven channel adapter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Interceptor on message driven channel adapter

    I do not seem to be able to get an interceptor to execute its when a message was received by message-driven-channel-adapter. Is this expected behavior?

    I was trying to utilized the interceptor to validate all the correct messages headers were populated with valid values before processing the message.

  • #2
    Can you post your config?

    Comment


    • #3
      current config (sanitized):

      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <beans:beans xmlns="http://www.springframework.org/schema/integration"
      	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      	xmlns:beans="http://www.springframework.org/schema/beans"
      	xmlns:jms="http://www.springframework.org/schema/integration/jms"
      	xmlns:stream="http://www.springframework.org/schema/integration/stream"
      	xmlns:jee="http://www.springframework.org/schema/jee"
      	xsi:schemaLocation="http://www.springframework.org/schema/beans
      			http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
      			http://www.springframework.org/schema/integration
      			http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
      			http://www.springframework.org/schema/integration/jms
      			http://www.springframework.org/schema/integration/jms/spring-integration-jms-1.0.xsd
      			http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
      			
      	<jee:jndi-lookup id="channel1Queue" jndi-name="MQ1" />
      	<jee:jndi-lookup id="channel2Queue" jndi-name="MQ2" />
      	<jee:jndi-lookup id="channel3Queue" jndi-name="MQ3" />
      	
      	
      	<channel id="channel1In">
      		<interceptors>
      			<beans:ref bean="validatingInterceptor" />
      		</interceptors>
      	</channel>
      	
      	<channel id="channel2In"/>
      	<channel id="channel2Out"/>
      	<channel id="channel3In"/>
      	<channel id="channel3Out"/>
      	
      	<beans:bean id="validatingInterceptor" class="com.ValidatingInterceptor"/>
      	
      
      	<jms:message-driven-channel-adapter id="channel1ChannelAdapter" 
      		container="channel1ListenerContainer" channel="channel1In" message-converter="myConverter"/>	
      
      	<jms:message-driven-channel-adapter id="channel2ChannelAdapter" 
      		container="channel2ListenerContainer" channel="channel2In"  message-converter="myConverter"/>
      		
      	<jms:message-driven-channel-adapter id="channel3ChannelAdapter" 
      		container="channel3ListenerContainer" channel="channel3Out"  message-converter="myConverter"/>		
      
      	
      	<jms:outbound-channel-adapter id="channel2OutAdapter" jms-template="channel2ChannelJmsTemplate" channel="channel2Out" />
      	<jms:outbound-channel-adapter id="channel3OutAdapter" jms-template="channel3ChannelJmsTemplate" channel="channel3Out" />	
      
      	 <chain id="channel1Chain" input-channel="channel1In">
      	 	 <router ref="myRouter" method="determineChannel" default-output-channel="channel3Out"/>
      	 </chain>
      							
      	<chain id="channel2Chain" input-channel="channel2In"> 
      	    <service-activator ref="noopHandler" method="handleMessage"/>
      	</chain>
      
      	 <chain id="channel3Chain" input-channel="channel3Out" >
      	     <service-activator ref="noopHandler" method="handleMessage"/>
      	 </chain>
      	 
      	 <!-- Router will return channel to use (channel2Out or channel3Out) -->
      	 <beans:bean id="myRouter" class="com.MyRouter"/>
      	 <!-- converts message to object and back to string -->
      	 <beans:bean id="myConverter" class="com.MyConverter"/>
      	 <!-- only logs message -->
      	 <beans:bean id="noopHandler" class="com.NoopHandler"/>
        
        	<!-- Message Listener Containers -->
      	<beans:bean id="channel1ListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
      		<beans:property name="concurrentConsumers" value="1" />
      		<beans:property name="maxConcurrentConsumers" value="1" />
      		<beans:property name="sessionTransacted" value="true"/>
      		<beans:property name="connectionFactory" ref="connectionFactory" />
      		<beans:property name="destination" ref="channel1Queue" />
      		<beans:property name="cacheLevelName" value="CACHE_NONE" />
      	</beans:bean>
      	
      	<beans:bean id="channel2ListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
      		<beans:property name="concurrentConsumers" value="1" />
      		<beans:property name="maxConcurrentConsumers" value="1" />
      		<beans:property name="sessionTransacted" value="true"/>
      		<beans:property name="connectionFactory" ref="connectionFactory" />
      		<beans:property name="destination" ref="channel2Queue" />
      		<beans:property name="cacheLevelName" value="CACHE_NONE" />
      	</beans:bean>
      	
      	<beans:bean id="channel3ListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
      		<beans:property name="concurrentConsumers" value="1" />
      		<beans:property name="maxConcurrentConsumers" value="1" />
      		<beans:property name="sessionTransacted" value="true"/>
      		<beans:property name="connectionFactory" ref="connectionFactory" />
      		<beans:property name="destination" ref="channel3Queue" />
      		<beans:property name="cacheLevelName" value="CACHE_NONE" />
      	</beans:bean>		
      
      	<!-- JMSTemplate Definitions -->
      	<beans:bean id="abstractJmsTemplate" class="org.springframework.jms.core.JmsTemplate" abstract="true">
      		<beans:property name="connectionFactory" ref="connectionFactory"/>
      		<beans:property name="sessionTransacted" value="true"/>
      		<beans:property name="messageIdEnabled" value="true"/>
      		<beans:property name="destinationResolver" ref="destinationResolver"/>
      	</beans:bean>
      	
      	<beans:bean id="channel1JmsTemplate" parent="abstractJmsTemplate">
      		<beans:property name="defaultDestination" ref="mq1" />
      	</beans:bean>
      	<beans:bean id="channe21JmsTemplate" parent="abstractJmsTemplate">
      		<beans:property name="defaultDestination" ref="mq2" />
      	</beans:bean>
      </beans:beans>

      Comment


      • #4
        It appears the messageconverter on the message-driven-channel-adapter gets called before the interceptor on the channel. I guess this was not what I was expecting. This tends to have me believe my impl is probably not ideal.

        Comment


        • #5
          Can you try adding a queue to the channel?

          Comment

          Working...
          X