Announcement Announcement Module
Collapse
No announcement yet.
Newb:header-enricher not adding value to message? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Newb:header-enricher not adding value to message?

    Hi,

    I am trying to use a Gateway to send a twitter DM message it all appears to be working apart from the fact it errors with:

    Code:
    java.lang.IllegalArgumentException: the header 'twitter_dmTargetUserId' must contain either a String (a screenname) or an int (a user ID)
    The following is my xml config:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    		http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
    		http://www.springframework.org/schema/integration/twitter http://www.springframework.org/schema/integration/twitter/spring-integration-twitter-2.0.xsd"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:int="http://www.springframework.org/schema/integration"
    	xmlns:int-twitter="http://www.springframework.org/schema/integration/twitter"
    	xmlns:util="http://www.springframework.org/schema/util">
    	
    	<context:property-placeholder location="classpath:oauth.properties"/>    
    	
    	<bean id="twitterTemplate"
    		class="org.springframework.integration.twitter.core.Twitter4jTemplate">
    		<constructor-arg value="${twitter.oauth.consumerKey}" />
    		<constructor-arg value="${twitter.oauth.consumerSecret}" />
    		<constructor-arg value="${twitter.oauth.accessToken}" />
    		<constructor-arg value="${twitter.oauth.accessTokenSecret}" />
    	</bean>
    	
    	<int:channel id="twitterOut">
    		<int:interceptors>
    	   		<int:wire-tap channel="logger"/>
    		</int:interceptors>	
    	</int:channel>	
    	
    	<int-twitter:dm-outbound-channel-adapter 
      		twitter-template="twitterTemplate" 
      		channel="twitterOut"/>
     
    	<int:gateway id="notificationsService" error-channel="logger" service-interface="org.hf.test.NotificationsService" default-request-channel="twitterMessageTransformer"></int:gateway>
    	
    	<int:channel id="logger"></int:channel>
    	<int:logging-channel-adapter channel="logger"></int:logging-channel-adapter>
    	 	
    	<int:channel id="twitterMessageTransformer">
    		<int:interceptors>
    	   		<int:wire-tap channel="logger"/>
    		</int:interceptors>		
    	</int:channel>
    	 
    	<int:header-enricher input-channel="twitterMessageTransformer" output-channel="twitterOut">
    		<int:header name="twitter_dmTargetUserId" value="JT_DEV"></int:header>
    	</int:header-enricher>
    </beans>
    I thought that this config should add the correct parameters:

    <int:header-enricher input-channel="twitterMessageTransformer" output-channel="twitterOut">
    <int:header name="twitter_dmTargetUserId" value="JT_DEV"></int:header>
    </int:header-enricher>

    I realise in a real app you would probably use a Transformer to dynamically add data, but this is only for testing.

    I've tried sending it direct from the code, which works fine i.e:

    Code:
    MessageChannel twitterOutChannel = context.getBean("twitterOut", MessageChannel.class);
    Message twitterUpdate = MessageBuilder.withPayload("hello")
            .setHeader(TwitterHeaders.DM_TARGET_USER_ID, "JT_DEV").build();
    twitterOutChannel.send(twitterUpdate);
    I've tried replacing the enricher with a transformer and calls to a service to return a new message and still keep hitting the same problem.

    Any help would be appreciated as I'm just finding my feet with SI!

    Thanks!

    Jim.
    Last edited by lo_jim; Apr 11th, 2012, 11:37 AM.

  • #2
    Problem solved - My annotation in my service layer was bypassing the enricher! Doh.

    Comment

    Working...
    X