Spring 集成入站 Http 网关分块 json 对 POST 请求的响应

Spring integration Inbound Http gateway chunking json response for POST request

我正在尝试使用 spring 集成的入站 http 网关。下面是我的配置。

<int:channel id="requestChannel" />
<int:channel id="responseChannel" />


<int-http:inbound-gateway id="inboundEmployeeSearchRequestGateway"
    supported-methods="POST" request-channel="requestChannel"
    reply-channel="responseChannel"
    mapped-response-headers="Return-Status, Return-Status-Msg, HTTP_RESPONSE_HEADERS"
     path="/services/{parama}/{paramb}/search"
    reply-timeout="6000000000">

    <int-http:header name="parama" expression="#pathVariables.parama" />
    <int-http:header name="paramb" expression="#pathVariables.paramb" />

</int-http:inbound-gateway>



<int:service-activator id="activator"
    input-channel="requestChannel" output-channel="responseChannel"
    ref="execSearch" method="execute" requires-reply="true"
    send-timeout="6000000000" />

我的服务激活码如下:

@Service
public class ExecutionService {

    @Autowired
    private AppDao appDao;

    public SQLResponse execute(Message<?> msg) throws Exception {
        SQLResponse response = new SQLResponse();
        Map<String,String> map = new HashMap<>();
        map.put("name","test");
        response.setResult(map);
        return response;
    }
}

但我的响应变得分块,只有当我使用 POST 使用服务时才会发生这种情况,而 GET 功能完美无缺。请帮助

什么应用服务器?我刚刚尝试使用 Tomcat 和 Jackson 消息转换器将地图转换为 JSON,但它不适合我。

您使用的是哪个消息转换器?

分块到底有什么问题?

我正在使用 tomcat 并且该应用程序是 Spring 基于引导的。以下 link 帮助我解决了这个问题。 http://forum.spring.io/forum/spring-projects/integration/109102-content-length-in-http-inbound-gateway-reply-channel。但我不需要提及 link 中描述的任何视图解析器。只需将入站的 mapped-response-headers="Return-Status, Return-Status-Msg, HTTP_RESPONSE_HEADERS" 更改为 mapped-response-headers="Content-Type"网关