Spring integration 发布空负载-入站网关

Spring integration 发布空负载-入站网关,spring-integration,Spring Integration,我有以下配置 <int-http:inbound-gateway request-channel="RequestChannel" path="/contractName/-/{resource}/**" supported-methods="POST,PUT,PATCH,DELETE" request-payload-type="java.util.LinkedHashMap" error-channel="ErrorChannel"

我有以下配置

<int-http:inbound-gateway request-channel="RequestChannel"
    path="/contractName/-/{resource}/**" 
            supported-methods="POST,PUT,PATCH,DELETE"
    request-payload-type="java.util.LinkedHashMap"
    error-channel="ErrorChannel"
    id="InboundGateway"  >
</int-http:inbound-gateway>

当将json发布到服务器时,负载会按预期转换为LinkedHashMap,但是在某些情况下,我需要发布一个没有负载的请求,当发布一个空负载时,转换会因请求错误而失败。只是想知道在配置中是否有一个简单/快速的解决方法,如果负载为空,我可以告诉它跳过转换。目前我需要发布“{}”,它才能工作


非常感谢。

我看到的唯一方法是编写一些定制的
HttpMessageConverter
。我想您只需要覆盖一点映射Jackson2HttpMessageConverter,为空请求正文填充一个空的映射。

谢谢。这似乎奏效了。我想知道是否有更好的方法来创建新消息,即没有HttpInputMessageBuilder?没有。因为消息没有提供空
负载的约定。如果您要启动下游,您应该提供一些有效的负载,即使它只是一个空字符串或列表。所以,如果客户端发送空请求是正常的,那么入站端点应该将其视为有效的消息负载,因为消息传递只是禁止它。我想
NullRequestHttpMessageConverter
可能也能帮到你。