In my app I'm trying to route based on returned http status values from a service method, and the rest of http statuses are to be routed to a default error channel. But this default mapping is not working,
@Bean
public IntegrationFlow bridgeFlow() {
return IntegrationFlows.from(ApplicationConfiguration.QUEUE_CHANNEL)
.bridge(e -> e.poller(Pollers.fixedDelay(2500).maxMessagesPerPoll(MAX_MSG_PER_POLL)))
.handle(someService, "someMethod")
.route(router())
.get();
}
public ExpressionEvaluatingRouter router() {
ExpressionEvaluatingRouter router = new ExpressionEvaluatingRouter("headers['httpStatus']");
router.setChannelMapping("422", REJECTED_QUEUE_CHANNEL);
router.setChannelMapping("202", "nullChannel");
router.setChannelMapping("201", "nullChannel");
router.setDefaultOutputChannelName(ORR_FAILED_QUEUE_CHANNEL);// When I receive other status codes it should go into this channel. But it's not going and throwing a runtime exception when a status code other than these is received.
return router;
}
I tried putting the default channel after .route(router()).channel(ORR_FAILED_QUEUE_CHANNEL) and also as .route(router()).handle(ORR_FAILED_QUEUE_CHANNEL). But it failed during bean initialization saying The 'currentComponent' (org.springframework.integration.router.ExpressionEvaluatingRouter@1ca574db) is a one-way 'MessageHandler' and it isn't appropriate to configure 'outputChannel'. This is the end of the integration flow.