简体   繁体   English

MessageStore支持的QueueChannel具有Spring Integration + Java Config

[英]MessageStore backed QueueChannel with Spring Integration+ Java Config

The Spring Integration reference guide refers to using a MessageStore implementation to provide persistence to a QueueChannel. Spring Integration 参考指南涉及使用MessageStore实现为QueueChannel提供持久性。

It's mentioned many times but all examples are using XML config, ie 提到过很多次,但是所有示例都使用XML配置,即

<int:channel id="dbBackedChannel">
    <int:queue message-store="channelStore"/>
</int:channel>

<bean id="channelStore" class="o.s.i.jdbc.store.JdbcChannelMessageStore">
    <property name="dataSource" ref="dataSource"/>
    <property name="channelMessageStoreQueryProvider" ref="queryProvider"/>
</bean>

But the implementation of QueueChannel has no methods for setting the MessageStore 但是QueueChannel的实现没有用于设置MessageStore的方法

So how could I create a QueueChannel with a MessageStore without using XML configuration? 那么,如何在不使用XML配置的情况下使用MessageStore创建QueueChannel?

Reverse engineered what the XML config did, and this is the answer. 对XML配置进行反向工程,这就是答案。

You have a wrap the MessageStore in a MessageGroupQueue 您将MessageStore包装在MessageGroupQueue中

So it would look something like this 所以看起来像这样

@Bean
public MessageChannel messageStoreBackedChannel() {
    return new QueueChannel(
        new MessageGroupQueue(<<MessageStoreImplementation>>, "Group ID")
    );
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM