Results 1 to 2 of 2

Thread: inbound gateway -> outbound gateway

  1. #1
    Join Date
    Sep 2008
    Posts
    2

    Default inbound gateway -> outbound gateway

    I'm trying to get my first spring integration sample to work.
    This is what I like to do:
    browser(http request) -> inbound gateway -> outbound gateway -> read index.html and return the response to the browser.

    Please can someone help me out to get this working. I get an exception when starting my server:
    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ConsumerEndpointFactoryBean#0': Cannot resolve reference to bean 'org.springframework.integration.config.ServiceActivatorFactoryBean#0' while setting bean property 'handler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ServiceActivatorFactoryBean#0': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Found ambiguous parameter type [interface java.util.List] for method match: [public void org.springframework.integration.handler.AbstractReplyProducingMessageHandler.setSendTimeout(long), public void org.springframework.integration.handler.AbstractMessageHandler.setOrder(int), public void org.springframework.integration.handler.AbstractReplyProducingMessageHandler.setChannelResolver(org.springframework.integration.support.channel.ChannelResolver), public void org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.setHeaderMapper(org.springframework.integration.mapping.HeaderMapper), public void org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.setExpectedResponseType(java.lang.Class), public void org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.setUriVariableExpressions(java.util.Map), public void org.springframework.integration.handler.AbstractMessageHandler.setShouldTrack(boolean), public void org.springframework.integration.context.IntegrationObjectSupport.setComponentName(java.lang.String), public final java.lang.String org.springframework.integration.context.IntegrationObjectSupport.getComponentName(), public void org.springframework.integration.handler.AbstractReplyProducingMessageHandler.setOutputChannel(org.springframework.integration.MessageChannel), public final void org.springframework.integration.context.IntegrationObjectSupport.setBeanFactory(org.springframework.beans.factory.BeanFactory), public void org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.setRequestFactory(org.springframework.http.client.ClientHttpRequestFactory), public final void org.springframework.integration.handler.AbstractMessageHandler.handleMessage(org.springframework.integration.Message), public void org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.setErrorHandler(org.springframework.web.client.ResponseErrorHandler), public void org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.setHttpMethod(org.springframework.http.HttpMethod)]
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
    config:
    Code:
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:int="http://www.springframework.org/schema/integration" xmlns:int-http="http://www.springframework.org/schema/integration/http"
            xmlns:util="http://www.springframework.org/schema/util"
            xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/http http://www.springframework.org/schema/integration/http/spring-integration-http-2.0.xsd
                    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
    
    
        <int-http:inbound-gateway id="gateway-in"
                                  request-channel="requestChannel"
                                  reply-channel="replyChannel"/>
    
        <bean id="gateway-out" class="org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler">
            <constructor-arg value="http://localhost:8080/index.html"/>
            <property name="outputChannel" ref="replyChannel"/>
        </bean>
    
        <int:service-activator input-channel="requestChannel"
                               output-channel="replyChannel"
                               ref="gateway-out"/>
    
        <int:channel id="requestChannel"/>
        <int:channel id="replyChannel"/>
    
    </beans>

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    There are couple of issues.
    First if you really want your configuration to work you need to add 'method="handleMessage"' attribute to your service-activator configuration since HttpRequestExecutingMessageHandler has several methods thus creating an ambiguity.
    Having said that your configuration could be much simpler for the use case you are describing. You don't need a service-activator at all. All you need is connect inbound with outbound via channel
    Code:
    <int-http:inbound-gateway id="gateway-in"
                                  request-channel="requestChannel"/>
    
    <int-http:outbound-gateway request-channel="requestChannel" 
    	url="http://localhost:8080/. . ."
    	http-method="GET"/>" 
    
    
    <int:channel id="requestChannel"/>
    Note, how there is no need to define an explicit reply-channel as one will be auto-created

Posting Permissions

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