Reputation: 1163
i have 2 flows
One is an http inbound gateway
return IntegrationFlow.from((Http.inboundGateway(getEndpointUrl())
.requestMapping(r -> r.methods(HttpMethod.valueOf(getHttpMethodType()))
.headerMapper(httpHeaderMapper())
.requestPayloadType(String.class)
.replyTimeout(getHttpReplyTimeout())
.errorChannel(adapterErrorChannel())))
.handle(validationService, "validationService")
.enrichHeaders(h -> h.headerFunction("some-id", m -> UUID.randomUUID().toString()))
.publishSubscribeChannel(c -> c
.subscribe(s -> s
.routeToRecipients(r -> r
.recipient("backupAChannel", m -> doBackupA())
.recipient("backupBChannel", m -> doBackupB())
.defaultOutputToParentFlow())
.channel("nullChannel"))
.subscribe(s -> s
.handle(messagePayloadService, "mapMessagePayload")
.enrich(e -> e.requestChannel("claimCheck.input").headerExpression("claimCheck", "payload"))
.handle("integrationGateway", "process")))
.get();
After the HTTP input is received successfully, I create a response and send it out with the following
MessageChannel replyChannel = (MessageChannel) headers.get("replyChannel");
...
return replyChannel.send(MessageBuilder.withPayload(json).setHeader(HttpHeaders.STATUS_CODE,
"Im a teapot").setHeader("Content-Type", HEADER_FMT).build());
The json has the format {"a": "b"}
The response IS being built but it is not being sent back to whoever sent data to the http inbound gateway
Instead of status "Im a teapot" they get 200 and no json
In the response builder code above, replyChannel has the value GenericMessagingTemplate$TemporaryReplyChannel@12345
What's odd to me is errorChannel shows the same value.
Is that how default channels are supposed to work?
The other flow is
return f -> f
.<MessageItemPayloadInterface>handle((p, h) -> {
Object o = getOutput(p, h);
if (o == null) {
return null;
}
return o;
}, e -> e.id("channelA"))
.<MessageItemPayloadInterface>handle((p, h) -> {
saveData(p, h);
return p;
}, e -> e.id("channelB").transactional(true))
.enrichHeaders(h -> h.headerFunction(IntegrationHeaders.PRODUCER_EVENT_KEY,
m -> {
String header = generateHeader(m.getPayload(), m.getHeaders());
return header == null ? "" : header;
}))
.<MessageItemPayloadInterface>handle((p, h) -> {
Object o = tellTheWorld(p, h);
if (o == null {
return null;
}
return o;
}, e -> e.id("channelC"))
.publishSubscribeChannel(a -> a
.subscribe(b -> b
.routeToRecipients(r -> r
.recipient("channelD", true)
.defaultOutputToParentFlow())
.channel("nullChannel"))
.subscribe(d -> d
.handle((p, h) -> {
housekeeping();
return p;
})
.channel("nullChannel")))
.channel("nullChannel");
and its reply channel and error channel are the same as the http inbound gateway's
Which really is confusing. Are they supposed to be shared across diff flows?
The problem is, it looks like the output of the 2nd flow is being returned to whoever called the http inbound gateway.
The original code was written in spring integration 5.5.11 and the misbehaving code has been upgraded to spring integration 6.1.5
Why isn't the expected output of the http inbound gateway flow being sent to the caller?
Why is the expected output of the 2nd flow being sent instead?
Is this some kind of fundamental change between versions?
EDIT: 01/16 I have reformatted this post, answered some questions and provided additional details at spring integration flow loses response - with added information
Upvotes: 0
Views: 97