Home > front end >  Spring Integration - replace XML by annotation, how to convert anonymous channels?
Spring Integration - replace XML by annotation, how to convert anonymous channels?

Time:11-28

I am converting Spring Integration beans from XML to annotations. In my XML, I have the following transformer:

<int:transformer ref="..." input-channel="in" output-channel="out">
    ...
</int:transformer>

I replaced this with:

@Transformer(inputChannel = "in", outputChannel = "out")

Here, the out channel is nowhere defined, it is anonymous. This no longer works in annotation, I get:

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean named 'out' that could not be found.

I should manually create such channel. My question is if the following is the correct and equivalent counter part of the implicit channel creation which is happening when using XML notation?

@Bean
public QueueChannel out() {
    return new QueueChannel();
}

That is, is QueueChannel the correct channel type here?

It seems to work, but I am not sure if both solution are fully equal.

CodePudding user response:

@Transformer(inputChannel = "in", outputChannel = "out.input")

or define channel name manualy

@Bean public MessageChannel out() { return MessageChannels.direct("out").get(); }

  • Related