本文介绍了具有Spring Integration + Java Config的MessageStore支持的QueueChannel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring Integration 参考指南是指使用MessageStore实现为QueueChannel提供持久性.

The Spring Integration reference guide refers to using a MessageStore implementation to provide persistence to a QueueChannel.

它被多次提及,但是所有示例都使用XML配置,即

It's mentioned many times but all examples are using XML config, i.e

<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>

但是 QueueChannel 没有设置MessageStore的方法

But the implementation of QueueChannel has no methods for setting the MessageStore

那么如何在不使用XML配置的情况下使用MessageStore创建QueueChannel?

So how could I create a QueueChannel with a MessageStore without using XML configuration?

推荐答案

对XML配置进行反向工程,这就是答案.

Reverse engineered what the XML config did, and this is the answer.

您将MessageStore包装在 MessageGroupQueue

You have a wrap the MessageStore in a MessageGroupQueue

所以看起来像这样

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

这篇关于具有Spring Integration + Java Config的MessageStore支持的QueueChannel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 17:50