2

I am trying to upgrade the spring integration flow in one of my existing application with Reactive Streams Support. The approach taken is to change the parameter and return type of the Gateway method as Mono. The flow executes smoothly and when the reply reaches the Gateway, it results in java.lang.IllegalArgumentException: 'beanFactory' must not be null

I am using Spring Boot 2.3.0.

inputChannel is a DirectChannel

gatewayReplyChannel is a FluxMessageChannel

@MessagingGateway(name = "reactiveGateway")
public interface EntryGate {

    @Gateway(requestChannel = "inputChannel", replyChannel = "gatewayReplyChannel")
    Mono<String> process(final Mono<String> input);

}

Exceptions trace

Caused by: java.lang.IllegalArgumentException: 'beanFactory' must not be null
    at org.springframework.util.Assert.notNull(Assert.java:198)
    at org.springframework.integration.channel.ChannelUtils.getErrorHandler(ChannelUtils.java:51)
    at org.springframework.integration.endpoint.ReactiveStreamsConsumer.onInit(ReactiveStreamsConsumer.java:155)
    at org.springframework.integration.context.IntegrationObjectSupport.afterPropertiesSet(IntegrationObjectSupport.java:214)
    at org.springframework.integration.gateway.MessagingGatewaySupport.registerReplyMessageCorrelatorIfNecessary(MessagingGatewaySupport.java:806)
    at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveMessageReactive(MessagingGatewaySupport.java:609)
    at org.springframework.integration.gateway.GatewayProxyFactoryBean.sendOrSendAndReceive(GatewayProxyFactoryBean.java:639)
    at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:573)

Can anyone help?

garuna
  • 21
  • 2

1 Answers1

1

The MessagingGatewaySupport.registerReplyMessageCorrelatorIfNecessary() has to be fixed to call endpoint.setBeanFactory(beanFactory); for the ReactiveStreamsConsumer. Apparently we just don't have a test case to cover the replyChannel as a FluxMessageChannel.

Consider to not use that replyChannel at all as a workaround. It is really doesn't matter for this kind of flow: it is already reactive by the Mono return type. No reason to shift to other reactive stream internally for the reply correlation.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118