Announcement Announcement Module
Collapse
No announcement yet.
http:outbound-gateway works in 1.0.4 but not in 2.0.m6 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • http:outbound-gateway works in 1.0.4 but not in 2.0.m6

    1.0.4 configuration looks like below. The message is a HashMap that arrives on request channel "httpPostChannel"

    <bean id="commonsExecutor" class="org.springframework.integration.http.Common sHttpRequestExecutor"/>

    <http:outbound-gateway id="httpMessageOutbound"
    request-channel="httpPostChannel"
    default-url="https://www.mycompany.com/webservice/REST/"
    request-timeout="500000"
    extract-request-payload="true"
    reply-channel="replyChannel"
    request-executor="commonsExecutor"/>
    However the above config in 2.0.m6 with slight modifications doesnot work


    <beans:bean id="commonsExecutor" class="org.springframework.http.client.CommonsClie ntHttpRequestFactory"/>
    <beans:bean id="mapMessageConverter" class="org.springframework.http.converter.FormHttp MessageConverter"/>

    <http:outbound-gateway id="httpMessageOutbound" request-factory="commonsExecutor" http-method="post"
    request-channel="httpPostChannel"
    url="https://www.mycompany.com/webservice/REST/"
    extract-request-payload="true"
    expected-response-type="java.lang.String"
    reply-channel="replyChannel" message-converters="mapMessageConverter"/>
    Again my Spring Integration message payload is of type HashMap.
    I am guessing that my converter is not appropriate here.
    Is that right? What am i doing wrong here?
    Do we have a converter that converts HashMap message?
    Or can i use request-executor in SI 2.0.m6?
    Thanks
    sri

  • #2
    Have you tried without any "message-converters" reference? There are some converters registered by default.

    Comment


    • #3
      I tried it and i get the same error as before
      Caused by: org.springframework.web.client.RestClientException : Could not write request: no suitable HttpMessageConverter found for request type [java.util.HashMap] and content type [application/x-www-form-urlencoded]
      at org.springframework.web.client.RestTemplate$HttpEn tityRequestCallback.doWithRequest(RestTemplate.jav a:597)
      at org.springframework.web.client.RestTemplate.doExec ute(RestTemplate.java:436)
      at org.springframework.web.client.RestTemplate.execut e(RestTemplate.java:409)
      at org.springframework.web.client.RestTemplate.exchan ge(RestTemplate.java:384)
      at org.springframework.integration.http.HttpRequestEx ecutingMessageHandler.handleRequestMessage(HttpReq uestExecutingMessageHandler.java:173)
      ... 40 more
      Originally posted by Mark Fisher View Post
      Have you tried without any "message-converters" reference? There are some converters registered by default.

      Comment


      • #4
        Is there any chance you can upgrade to 2.0 M7? ... at least to try this out. We added a feature where a Map is converted to a MultiValueMap which is supported by the converters.

        Comment


        • #5
          is conversion of map to multivaluemap a default converter in 2.0.m7?
          I can try this, but i am afraid of the stability of this release which is still not a GA. The console app that i am developing will go in production in another month.

          I will update my findings as soon as i have them.
          Thanks
          sri
          Originally posted by Mark Fisher View Post
          Is there any chance you can upgrade to 2.0 M7? ... at least to try this out. We added a feature where a Map is converted to a MultiValueMap which is supported by the converters.

          Comment


          • #6
            We will be releasing RC1 within a week, and I would highly recommend updating to that as soon as possible. I would not recommend going into production on any milestone, but while in development mode, the later the milestone the better - because you will be closer to the code that is going to be in the RC/GA release.

            Comment


            • #7
              Hi mark,
              Sorry for delay. I basically did two things to make it work with 2.0.m6
              I transformed my HashMap payload to MultiValueMap.
              I also added two message converters namely FormHttpMessageConverter, StringHttpMessageConverter to convert my request as well as my response.

              For now this seems to work. however for production, i will revert this back to 1.0.4 or the latest RC1.
              I have a follow up question on this.
              I have set the reply-channel where i have set the response type String.
              However the response is actually a HTTP status code 200, 401 etc.
              How do i capture this and do the needful?
              Thanks
              sri

              Originally posted by Mark Fisher View Post
              We will be releasing RC1 within a week, and I would highly recommend updating to that as soon as possible. I would not recommend going into production on any milestone, but while in development mode, the later the milestone the better - because you will be closer to the code that is going to be in the RC/GA release.

              Comment


              • #8
                Can you try adding the following attribute and value to the outbound-gateway:
                expected-response-type="java.lang.String"

                Please let me know if that helps.
                Thanks,
                Mark

                Comment


                • #9
                  Hi Mark,
                  Yes, i had that from begining and it started working only after adding StringMessageConverter to the list of message-converters.

                  A differet question: What is spring-integration-parent ?
                  My team members keep getting this, but i don't.
                  After checking my .m2 local repository, i have 'spring-integration-parent' folder created along with other folders for needed jars.
                  Should i add anything to my pom file to get this folder which has parent pom file?

                  Originally posted by Mark Fisher View Post
                  Can you try adding the following attribute and value to the outbound-gateway:
                  expected-response-type="java.lang.String"

                  Please let me know if that helps.
                  Thanks,
                  Mark

                  Comment


                  • #10
                    'spring-integration-parent' is a parent POM to all SI modules, but I am not sure why you need it. In other words when developing against SI with maven you never have to include it explicitly.

                    As far as the original problem and your concerns around the stability, there was a major refactoring done to several components between M6 and M7 with HTTP being one of them all for the purpose of making it more stable, consistent and feature-full, so I would definitely upgrade to M7 and then RC1 as soon as it is released.

                    Comment


                    • #11
                      Hi olga,
                      I will upgrade to m7 and will retry it. However, i also need to add erroHandler to do the needful for 5 different http return status codes. As far as i know from past forum messages from Mark, this is not allowed in m7, but has been made available through nightly builds.
                      Can i get just spring integration http jar from nightly build and expect to see namespace configuration for custom error handler?
                      Is this also an issue with other adapters?
                      Thanks
                      Sri

                      Originally posted by oleg.zhurakousky View Post
                      'spring-integration-parent' is a parent POM to all SI modules, but I am not sure why you need it. In other words when developing against SI with maven you never have to include it explicitly.

                      As far as the original problem and your concerns around the stability, there was a major refactoring done to several components between M6 and M7 with HTTP being one of them all for the purpose of making it more stable, consistent and feature-full, so I would definitely upgrade to M7 and then RC1 as soon as it is released.

                      Comment


                      • #12
                        RC1 release is literally around the conner (~week). So i would say for you switching to nightly builds would be safe. 2.0.0.BUILD-SNAPSHOT
                        Here are the repositories that you should use:
                        Code:
                        <repository>
                           <id>repository.springframework.maven.snapshot</id>
                           <name>Spring Framework Maven Snapshot Repository</name>
                           <url>http://maven.springframework.org/snapshot</url>
                        </repository>

                        Comment


                        • #13
                          Hi Oleg, Mark
                          I will start using this nightly build and build the application starting tomorrow. This app needs to go to Testing in another 3 weeks.
                          I have a quick question and an answer to this will greatly help me.

                          Assuming i am able to add my own responseHandler to look at the HttpStatus codes and do the needful based on certain status codes, will i be able to get access to my Original request that resulted in the response?
                          If yes, how?
                          Thanks
                          sri

                          Comment

                          Working...
                          X