Spring integration 如何在Spring集成中使用HTTP 204进行响应

Spring integration 如何在Spring集成中使用HTTP 204进行响应,spring-integration,dsl,Spring Integration,Dsl,我有一个系统使用spring集成来交换数据。 AppClient使用TableInfoRequest请求AppServer,AppServer将响应TableInfoResponse。现在工作正常 @MessagingGateway() public interface SyncGateway { @Gateway(requestChannel = "requestFlow.input") TableInfoResponse info(TableInfoRequ

我有一个系统使用spring集成来交换数据。 AppClient使用TableInfoRequest请求AppServer,AppServer将响应TableInfoResponse。现在工作正常

@MessagingGateway() public interface SyncGateway { @Gateway(requestChannel = "requestFlow.input") TableInfoResponse info(TableInfoRequest payload); } @MessagingGateway() 公共接口同步网关{ @网关(requestChannel=“requestFlow.input”) TableInfoResponse信息(TableInfoRequest有效载荷); } 但是我想在没有数据响应时使用http代码204进行响应,这将减少响应中的数据。那么如何设置DSL呢?

@豆子 公共集成流同步流(){ 返回积分流 .来自( Http.inboundGateway(Http\u ENDPOINT\u PATH).id(“syncGateway”) .replyTimeout(serverProps.getReplyTimeout()*1000) .requestTimeout(serverProps.getRequestTimeout()*1000) .messageConverters(新的SerializingHttpMessageConverter()) .1例外情况(真) .mappedResponseHeaders(标识、令牌)) .频道(c->c.direct(“同步频道”) .interceptor(新的ChannelAuthenticationInterceptor(数据服务))) .handle(syncHandler) .get(); }
syncHandler将返回TableInfoResponse。AppClient使用syncGateway.info(请求)获取TableInfoResponse。

在回复消息中设置
HttpHeaders.STATUS\u code
标题(
HttpStatusCode
)。

设置
HttpHeaders.STATUS\u code
标题(
HttpStatusCode>)在回复信息中。

只需使用:

 .statusCodeFunction(m -> HttpStatus.NO_CONTENT)
e、 g

只需使用:

 .statusCodeFunction(m -> HttpStatus.NO_CONTENT)
e、 g


换句话说,如果你想返回
204 No Content
reply,你真的应该这样做-用
HttpStatus回复Inbond网关。No_Content
:谢谢你的回答。但是我不明白在没有数据的情况下如何回复204
.handle(syncHandler)
还将回复一个对象。AppClient还希望接收一个对象-
。expectedResponseType(Serializable.class)
换句话说,如果您希望返回
204无内容
回复,你真的应该这样做-用
HttpStatus回复Inbond网关。无内容
:谢谢你的回答。但是我不明白没有数据时如何回复204
.handle(syncHandler)
还将回复一个对象。AppClient还希望接收一个对象-
。expectedResponseType(Serializable.class)
@Bean
      public IntegrationFlow syncFlow() {
        return IntegrationFlows
            .from(
              Http.inboundGateway(HTTP_ENDPOINT_PATH).id("syncGateway")
                .replyTimeout(serverProps.getReplyTimeout() * 1000)
                .requestTimeout(serverProps.getRequestTimeout() * 1000)
                .statusCodeFunction(m -> HttpStatus.NO_CONTENT)
                .messageConverters(new SerializingHttpMessageConverter())
                .convertExceptions(true)
                .mappedResponseHeaders(IDENTIFICATION, TOKEN))
            .channel(c -> c.direct("syncChannel")
                .interceptor(new ChannelAuthenticationInterceptor(dataService)))
            .handle(syncHandler)
            .get();
      }