MessageStore backed QueueChannel with Spring Integration+ Java Config

ⅰ亾dé卋堺 提交于 2019-12-20 04:28:38

问题


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

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>

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

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


回答1:


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

You have a wrap the MessageStore in a MessageGroupQueue

So it would look something like this

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


来源:https://stackoverflow.com/questions/32538885/messagestore-backed-queuechannel-with-spring-integration-java-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!