Announcement Announcement Module
Collapse
No announcement yet.
HttpRequestHandlingMessagingGateway and delayed JSON response Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HttpRequestHandlingMessagingGateway and delayed JSON response

    I've written a simple server using Spring Integration which sends a HTTP response to a HTTP request. It works fine when the request/response payload is text/plain, however I would like to use JSON. When I do this it works but the response is delayed by about 25 secs. I seems like something isn't being closed/flushed as if I stop Tomcat during this delay the response is received instantly. Like I say, this delay does not occur when using a string payload. Any help much appreciated as I've spent a while trying to get past this.

    I'm using Tomcat 6, Spring 3.0.5, Spring Integration 2.0.5 and Jackson Core and Mapper 1.8.5. I've simplified my server as much as possible to eliminate other factors.

    the JSON request (sent with Poster)
    Code:
    Content-Type: application/json
    Accept-Charset: utf-8
    {"message": "HELLO WORLD" }
    web.xml
    Code:
            <servlet>
    		<servlet-name>Dispatcher</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<init-param>
    			<param-name>contextConfigLocation</param-name>
    			<param-value>/WEB-INF/servlet-config.xml</param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>Dispatcher</servlet-name>
    		<url-pattern>/*</url-pattern>
    	</servlet-mapping>
    servlet-config.xml
    Code:
    	<bean name="/test" class="org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway">
    		<property name="replyChannel" ref="outChannel"/>
    		<property name="requestChannel" ref="inChannel"/>
    		<property name="requestPayloadType" value="blah.Configuration"/>
    	</bean>
    	
    	<int:channel id="inChannel"/>
    	<int:channel id="outChannel"/>
    	
    	<int:service-activator input-channel="inChannel" output-channel="outChannel" requires-reply="true" ref="consumer" method="consumeMessage"/>
    
    	<bean id="consumer" class="blah.Consumer"/>
    Consumer.java
    Code:
    public class Consumer {
        public Configuration consumeMessage(Message<Configuration> message) {
            return message.getPayload();
        }
    }
    Configuration.java
    Code:
    public class Configuration {
        private String message;
    
        public String getMessage() {
            return message;
        }
    
        public void setMessage(String message) {
            this.message = message;
        }
    }

  • #2
    solved

    solved. i had a trailing newline character in my JSON data. removed that and it all works perfectly.

    Comment

    Working...
    X