Announcement Announcement Module
Collapse
No announcement yet.
GatewayProxyFactoryBean default-reply-channel not resolved Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • GatewayProxyFactoryBean default-reply-channel not resolved

    I am trying to wire up a gateway.

    I have the following working:

    Code:
     jmsGateway(org.springframework.integration.gateway.SimpleMessagingGateway) {
        requestChannel = ref("routerChannel")
        replyChannel = ref("ShippingCostChannel")
        replyTimeout = "10000" 
      }
    (NB: this is with Grails' "Spring Beans DSL")

    I am interacting with this in a Grails controller as follows:

    Code:
      def send = {
    		def msg = params.content
        jmsGateway.send(msg)
        println "Sending '$msg'"
        def got = jmsGateway.receive()
    		//def got = '???'
        println "RECEIVED: '$got'"
        flash.message = got
        }
    If I try to use a gateway using GatewayProxyFactoryBean, I get errors.


    Code:
        gateway(id: "lookupService",
                "service-interface": "au.com.transentia.si.LookupService",
                "default-request-channel": "routerChannel",
                "default-reply-channel": "ShippingCostChannel",
                "default-reply-timeout": "10000")
    In the new controller:

    Code:
    	def send = {
    	  def msg = params.content
    	  flash.message = lookupService.lookup(msg)
    	}
    LookupService is:

    Code:
    package au.com.transentia.si
    
    public interface LookupService {
      String lookup(String who)
    }
    Here is a debug trace for the relevant part of the execution:

    Code:
    2009-04-10 11:10:45,511 [task-scheduler-3] DEBUG channel.QueueChannel  - preSend
     on channel 'ShippingCostChannel', message: [Payload=<?xml version="1.0" encodin
    g="UTF-8"?><ns1:calculateShippingCostResponse xmlns:ns1="http://DefaultNamespace
    "><ns1:return>0.0</ns1:return></ns1:calculateShippingCostResponse>][Headers={spr
    ingintegration_jms_messageId=ID:TRIFFID-49578-1239324670371-0:0:2:1:2, springint
    egration_timestamp=1239325845406, springintegration_id=0d7c3d9a-a3a7-4516-9841-6
    951d3779bf5, springintegration_jms_redelivered=false}]
    2009-04-10 11:10:45,511 [task-scheduler-3] DEBUG channel.QueueChannel  - postSen
    d (sent=true) on channel 'ShippingCostChannel', message: [Payload=<?xml version=
    "1.0" encoding="UTF-8"?><ns1:calculateShippingCostResponse xmlns:ns1="http://Def
    aultNamespace"><ns1:return>0.0</ns1:return></ns1:calculateShippingCostResponse>]
    [Headers={springintegration_jms_messageId=ID:TRIFFID-49578-1239324670371-0:0:2:1
    :2, springintegration_timestamp=1239325845406, springintegration_id=0d7c3d9a-a3a
    7-4516-9841-6951d3779bf5, springintegration_jms_redelivered=false}]
    2009-04-10 11:10:45,511 [task-scheduler-4] DEBUG channel.QueueChannel  - postRec
    eive on channel 'ShippingCostChannel', message: [Payload=<?xml version="1.0" enc
    oding="UTF-8"?><ns1:calculateShippingCostResponse xmlns:ns1="http://DefaultNames
    pace"><ns1:return>0.0</ns1:return></ns1:calculateShippingCostResponse>][Headers=
    {springintegration_jms_messageId=ID:TRIFFID-49578-1239324670371-0:0:2:1:2, sprin
    gintegration_timestamp=1239325845406, springintegration_id=0d7c3d9a-a3a7-4516-98
    41-6951d3779bf5, springintegration_jms_redelivered=false}]
    2009-04-10 11:10:45,514 [task-scheduler-4] DEBUG gateway.AbstractMessagingGatewa
    y$1  - org.springframework.integration.gateway.AbstractMessagingGateway$1@cead6
    received message: [Payload=<?xml version="1.0" encoding="UTF-8"?><ns1:calculateS
    hippingCostResponse xmlns:ns1="http://DefaultNamespace"><ns1:return>0.0</ns1:ret
    urn></ns1:calculateShippingCostResponse>][Headers={springintegration_jms_message
    Id=ID:TRIFFID-49578-1239324670371-0:0:2:1:2, springintegration_timestamp=1239325
    845406, springintegration_id=0d7c3d9a-a3a7-4516-9841-6951d3779bf5, springintegra
    tion_jms_redelivered=false}]
    2009-04-10 11:10:45,515 [task-scheduler-4] DEBUG channel.PublishSubscribeChannel
      - preSend on channel 'errorChannel', message: [Payload=org.springframework.int
    egration.channel.ChannelResolutionException: unable to resolve reply channel for
     message: [Payload=<?xml version="1.0" encoding="UTF-8"?><ns1:calculateShippingC
    ostResponse xmlns:ns1="http://DefaultNamespace"><ns1:return>0.0</ns1:return></ns
    1:calculateShippingCostResponse>][Headers={springintegration_jms_messageId=ID:TR
    IFFID-49578-1239324670371-0:0:2:1:2, springintegration_timestamp=1239325845406,
    springintegration_id=0d7c3d9a-a3a7-4516-9841-6951d3779bf5, springintegration_jms
    _redelivered=false}]][Headers={springintegration_timestamp=1239325845515, spring
    integration_id=68f36a77-69cc-41fa-9bae-58c2e941ab1a}]
    org.springframework.integration.channel.ChannelResolutionException: unable to re
    solve reply channel for message: [Payload=<?xml version="1.0" encoding="UTF-8"?>
    <ns1:calculateShippingCostResponse xmlns:ns1="http://DefaultNamespace"><ns1:retu
    rn>0.0</ns1:return></ns1:calculateShippingCostResponse>][Headers={springintegrat
    ion_jms_messageId=ID:TRIFFID-49578-1239324670371-0:0:2:1:2, springintegration_ti
    mestamp=1239325845406, springintegration_id=0d7c3d9a-a3a7-4516-9841-6951d3779bf5
    , springintegration_jms_redelivered=false}]
            at org.springframework.integration.handler.AbstractReplyProducingMessage
    Handler.resolveReplyChannel(AbstractReplyProducingMessageHandler.java:142)
            at org.springframework.integration.handler.AbstractReplyProducingMessage
    Handler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:102)
    ...
    It seems that postSend on the 'ShippingCostChannel' is not resolving correctly in this case...but it DOES if I use the SimpleMessagingGateway "by hand"...

    Any suggestions/thoughts?

    Cheers,

    Alph

  • #2
    If I use SimpleMessagingGateway as follows:

    Code:
      def send = {
        def msg = params.content
        flash.message = jmsGateway.sendAndReceive(msg)
        }
    I also get an error:

    Code:
    2009-04-10 11:35:57,208 [task-scheduler-2] DEBUG channel.QueueChannel  - preSend on channel 'ShippingCostChannel', message: [Payload=<?xml version="1.0" encoding="UTF-8"?><ns1:calculateShippingCostRes
    ponse xmlns:ns1="http://DefaultNamespace"><ns1:return>0.0</ns1:return></ns1:calculateShippingCostResponse>][Headers={springintegration_jms_messageId=ID:TRIFFID-49578-1239324670371-0:0:2:1:3, springint
    egration_timestamp=1239327355861, springintegration_id=e5d6fa28-6c34-41d1-93a3-822417317af4, springintegration_jms_redelivered=false}]
    2009-04-10 11:35:57,229 [task-scheduler-2] DEBUG channel.QueueChannel  - postSend (sent=true) on channel 'ShippingCostChannel', message: [Payload=<?xml version="1.0" encoding="UTF-8"?><ns1:calculateSh
    ippingCostResponse xmlns:ns1="http://DefaultNamespace"><ns1:return>0.0</ns1:return></ns1:calculateShippingCostResponse>][Headers={springintegration_jms_messageId=ID:TRIFFID-49578-1239324670371-0:0:2:1
    :3, springintegration_timestamp=1239327355861, springintegration_id=e5d6fa28-6c34-41d1-93a3-822417317af4, springintegration_jms_redelivered=false}]
    2009-04-10 11:35:57,229 [task-scheduler-4] DEBUG channel.QueueChannel  - postReceive on channel 'ShippingCostChannel', message: [Payload=<?xml version="1.0" encoding="UTF-8"?><ns1:calculateShippingCos
    tResponse xmlns:ns1="http://DefaultNamespace"><ns1:return>0.0</ns1:return></ns1:calculateShippingCostResponse>][Headers={springintegration_jms_messageId=ID:TRIFFID-49578-1239324670371-0:0:2:1:3, sprin
    gintegration_timestamp=1239327355861, springintegration_id=e5d6fa28-6c34-41d1-93a3-822417317af4, springintegration_jms_redelivered=false}]
    2009-04-10 11:35:57,277 [task-scheduler-4] DEBUG gateway.AbstractMessagingGateway$1  - org.springframework.integration.gateway.AbstractMessagingGateway$1@c3e952 received message: [Payload=<?xml versio
    n="1.0" encoding="UTF-8"?><ns1:calculateShippingCostResponse xmlns:ns1="http://DefaultNamespace"><ns1:return>0.0</ns1:return></ns1:calculateShippingCostResponse>][Headers={springintegration_jms_messag
    eId=ID:TRIFFID-49578-1239324670371-0:0:2:1:3, springintegration_timestamp=1239327355861, springintegration_id=e5d6fa28-6c34-41d1-93a3-822417317af4, springintegration_jms_redelivered=false}]
    2009-04-10 11:35:57,304 [task-scheduler-4] DEBUG channel.PublishSubscribeChannel  - preSend on channel 'errorChannel', message: [Payload=org.springframework.integration.channel.ChannelResolutionExcept
    ion: unable to resolve reply channel for message: [Payload=<?xml version="1.0" encoding="UTF-8"?><ns1:calculateShippingCostResponse xmlns:ns1="http://DefaultNamespace"><ns1:return>0.0</ns1:return></ns
    1:calculateShippingCostResponse>][Headers={springintegration_jms_messageId=ID:TRIFFID-49578-1239324670371-0:0:2:1:3, springintegration_timestamp=1239327355861, springintegration_id=e5d6fa28-6c34-41d1-
    93a3-822417317af4, springintegration_jms_redelivered=false}]][Headers={springintegration_timestamp=1239327357304, springintegration_id=4005416b-765c-4adc-81c8-4e6dced3e9de}]
    org.springframework.integration.channel.ChannelResolutionException: unable to resolve reply channel for message: [Payload=<?xml version="1.0" encoding="UTF-8"?><ns1:calculateShippingCostResponse xmlns
    :ns1="http://DefaultNamespace"><ns1:return>0.0</ns1:return></ns1:calculateShippingCostResponse>][Headers={springintegration_jms_messageId=ID:TRIFFID-49578-1239324670371-0:0:2:1:3, springintegration_ti
    mestamp=1239327355861, springintegration_id=e5d6fa28-6c34-41d1-93a3-822417317af4, springintegration_jms_redelivered=false}]
            at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.resolveReplyChannel(AbstractReplyProducingMessageHandler.java:142)
            at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:102)
            at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:48)
            at org.springframework.integration.endpoint.PollingConsumer.doPoll(PollingConsumer.java:59)
            at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.innerPoll(AbstractPollingEndpoint.java:232)
            at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.poll(AbstractPollingEndpoint.java:216)
            at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:209)
            at org.springframework.integration.scheduling.SimpleTaskScheduler$ErrorHandlingRunnableWrapper.run(SimpleTaskScheduler.java:307)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
            at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
            at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
            at org.springframework.integration.scheduling.SimpleTaskScheduler$TriggeredTask.run(SimpleTaskScheduler.java:256)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
            at java.lang.Thread.run(Thread.java:619)
    
    2009-04-10 11:35:57,482 [task-scheduler-4] DEBUG handler.LoggingHandler  - org.springframework.integration.handler.LoggingHandler@ad3fd4 received message: [Payload=org.springframework.integration.chan
    nel.ChannelResolutionException: unable to resolve reply channel for message: [Payload=<?xml version="1.0" encoding="UTF-8"?><ns1:calculateShippingCostResponse xmlns:ns1="http://DefaultNamespace"><ns1:
    return>0.0</ns1:return></ns1:calculateShippingCostResponse>][Headers={springintegration_jms_messageId=ID:TRIFFID-49578-1239324670371-0:0:2:1:3, springintegration_timestamp=1239327355861, springintegra
    tion_id=e5d6fa28-6c34-41d1-93a3-822417317af4, springintegration_jms_redelivered=false}]][Headers={springintegration_timestamp=1239327357304, springintegration_id=4005416b-765c-4adc-81c8-4e6dced3e9de}]
    This rather implies that I have forgotten some configuration...

    Again, suggestions gratefuly received.

    Alph

    Comment


    • #3
      Forgot the details...

      This is with Spring Integration 1.0.2
      Grails 1.1/Groovy 1.6.1
      Active MQ 5.2
      Java 1.6.0_12
      Vista SP1

      Comment


      • #4
        Ping!

        Nobody seen this behaviour before? It is quite reproduceable...

        Alph

        Comment


        • #5
          I haven't looked into this yet, but it's somewhere on my todo list. Don't hold your breath, but rest assured you are not being ignored.

          Comment


          • #6
            Thanks for taking the time to get back to me!

            I wasn't worried about being ignored...I realise (and appreciate) that you guys are out there working hard...

            I WAS worried about having done something stupid ;-)

            Cheers,

            Alph

            Comment


            • #7
              Does the interface that you are implementing via this gateway proxy have a 'replyChannel' attribute within a @Gateway annotation?

              Comment


              • #8
                No. The interface is purely configured via XML, as shown in my first post.

                My understanding is that @Gateway is optional(?)

                I'll try to add @Gateway and see if any change.

                Cheers,

                Alph

                Comment


                • #9
                  Sorry. My reply was a bit brief. The @Gateway annotation is optional on the interface. I was just wondering if perhaps you had that - thereby triggering the channel resolution based on a replyChannel there that overrides the default.

                  If you are using the defaultReplyChannel only and seeing that error, then I think it must be a bug.

                  Comment


                  • #10
                    Ah.

                    Any workaround come to mind (other than what I have done)?

                    Is there anything that I could do to help you confirm what is going on?

                    Cheers,

                    Alph

                    Comment


                    • #11
                      If you can provide an isolated test-case and submit it along with a new issue in JIRA that would be very helpful. The test-case should be in plain java if possible so that we can add it directly to the core test suite.

                      Thanks,
                      Mark

                      Comment


                      • #12
                        Just wanted to ensure that I have seen the same behaviour ("ChannelResolver is required for resolving a reply channel by name" although specified by the gateway) under a plain Java environment (using SI 1.0.2, Java 1.6, ActiveMQ 5.2). The following exception is thrown:

                        Code:
                        org.springframework.integration.message.MessageHandlingException: error occurred in message handler [org.springframework.integration.gateway.AbstractMessagingGateway$1@3cb5e07a]
                        	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:54)
                        	at org.springframework.integration.endpoint.PollingConsumer.doPoll(PollingConsumer.java:59)
                        	at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.innerPoll(AbstractPollingEndpoint.java:232)
                        	at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.poll(AbstractPollingEndpoint.java:216)
                        	at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:209)
                        	at org.springframework.integration.scheduling.SimpleTaskScheduler$ErrorHandlingRunnableWrapper.run(SimpleTaskScheduler.java:307)
                        	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
                        	at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
                        	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
                        	at org.springframework.integration.scheduling.SimpleTaskScheduler$TriggeredTask.run(SimpleTaskScheduler.java:256)
                        	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
                        	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
                        	at java.lang.Thread.run(Thread.java:637)
                        Caused by: java.lang.IllegalStateException: ChannelResolver is required for resolving a reply channel by name
                        	at org.springframework.util.Assert.state(Assert.java:384)
                        	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.resolveReplyChannel(AbstractReplyProducingMessageHandler.java:131)
                        	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:102)
                        	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:48)
                        	... 12 more
                        My (client-side) configuration looks like:

                        Code:
                        <gateway id="processingGateway"
                        	service-interface="com.example.integrations.IProcessingService"
                        	default-request-channel="clientRequestChannel"
                        	default-reply-channel="clientReplyChannel"/>
                        		  
                        <channel id="clientRequestChannel"/>
                        
                        <jms:outbound-gateway 
                        	request-channel="clientRequestChannel" 
                        	request-destination="requestQueue"
                        	reply-channel="clientReplyChannel"
                        	reply-destination="replyQueue"/>
                        
                        <channel id="clientReplyChannel"/>
                        The java interface looks like:

                        Code:
                        public interface IProcessingService {
                        
                            Object process(Map<String, Object> params);
                            
                        }

                        Comment


                        • #13
                          Based on a quick assessment, it looks like this is a different issue, because the earlier poster was seeing a channel resolution error while you are actually seeing an error due to no channel-resolver being present.

                          This is odd, because the default ChannelResolver should always be present.

                          Can you please submit an issue via JIRA (with failing test case if possible)? If we can reproduce this, we will try to resolve it for SI 1.0.3.

                          Thanks,
                          Mark

                          Comment


                          • #14
                            It turned out to be a problem on how I constructed the resulting message from my service activator. I was setting the reply channel explictly like...

                            Code:
                            return MessageBuilder.withPayload(msg)
                                .copyHeadersIfAbsent(msg.getHeaders())
                                .setHeader(JmsHeaders.CORRELATION_ID, msg.getHeaders().getId())
                                .setReplyChannelName("serverResponseChannel") // CAUSING EXCEPTION
                                .build();
                            ... this was causing the exception as cited in my previous post (missing channel resolver). When just leaving out the explict channel name setting all is working fine.

                            This is how the service activator is now defined (and working):
                            Code:
                            	<service-activator input-channel="serverRequestChannel" 
                            	        ref="processor" 
                            	        method="handle" 
                            	        output-channel="serverResponseChannel" />
                            Still I am not sure if setting the channel name should lead to a cannot resolve channel exception, worth a JIRA?

                            Regards,
                            Lars

                            Comment


                            • #15
                              Please do add an issue. Even if there is a problem resolving the channel, the exception should not be related to no ChannelResolver being present. Also, if the configuration you posted is working, then it would seem that the other code should also work. The default ChannelResolver should be able to determine the channel based on its name.

                              I'm wondering why the default resolver is not in place. Is there anything else different about your configuration that could affect this? For example, maybe you are not using Spring to configure some components?

                              Thanks,
                              Mark

                              Comment

                              Working...
                              X