春季集成 - 用@transformer符号注释的两个方法的两个变压器

发布于 2025-01-21 10:24:03 字数 531 浏览 1 评论 0原文

我有一种用@transform符号注释的方法。但是,在其他情况下,需要将此变压器用于不同的输入和输出通道。让我们认为我有这样的代码:

@Transformer(inputChannel = "myInputChannel", outputChannel = "myOutputChannel")
public Message<List<DataElement>> transformMyBusiness(Message<byte[]> message) throws Throwable {
    Message<List<CustomDataType>> incomingMessage = doAJob(message);
    return incomingMessage;
}

我还有另一个输入通道,即MyInputChannel2和输出通道MyOutputChannel2。这些输入和输出通道将使用上述变压器,但我不想复制该代码。

如何使用@transformer注释的两个变压器使用相同的方法?

I have a method which annotated with @Transformer notation. But, in other case needs to use this this transformer for different input and output channels. Let's think that I have a code like this:

@Transformer(inputChannel = "myInputChannel", outputChannel = "myOutputChannel")
public Message<List<DataElement>> transformMyBusiness(Message<byte[]> message) throws Throwable {
    Message<List<CustomDataType>> incomingMessage = doAJob(message);
    return incomingMessage;
}

I have another input channel which is myInputChannel2 and output channel myOutputChannel2. These input and output channels will use the above transformer but I don't want to duplicate that code.

How can I use same method for two transformers with @Transformer annotation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沩ん囻菔务 2025-01-28 10:24:03

现在是这样的:

@Transformer(inputChannel = "myInputChannel", outputChannel = "myOutputChannel")
@ServiceActivator(inputChannel = "myInputChannel2", outputChannel = "myOutputChannel2")
public Message<List<DataElement>> transformMyBusiness(Message<byte[]> message) throws Throwable {

尚无@repeatable对这些注释的支持,但我们确实牢记了: https://github.com/spring-projects/spring-integration/issues/sissues/2708

也许是时候再给它了...

This is possible now like this:

@Transformer(inputChannel = "myInputChannel", outputChannel = "myOutputChannel")
@ServiceActivator(inputChannel = "myInputChannel2", outputChannel = "myOutputChannel2")
public Message<List<DataElement>> transformMyBusiness(Message<byte[]> message) throws Throwable {

There is no @Repeatable support for these annotations yet, but we really have it in mind: https://github.com/spring-projects/spring-integration/issues/2708.

Perhaps it's time to give it a short again...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文