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)
web.xmlCode:Content-Type: application/json Accept-Charset: utf-8 {"message": "HELLO WORLD" }
servlet-config.xmlCode:<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>
Consumer.javaCode:<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"/>
Configuration.javaCode:public class Consumer { public Configuration consumeMessage(Message<Configuration> message) { return message.getPayload(); } }
Code:public class Configuration { private String message; public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } }


Reply With Quote
