栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在Spring Integration中为Redis创建MessageSource

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在Spring Integration中为Redis创建MessageSource

让我们从这里开始:[https](https://docs.spring.io/spring-
integration/docs/5.0.9.RELEASE/reference/html/overview.html#programming-tips)
//docs.spring.io/spring-
integration/docs/5.0.9.RELEASE/reference/html/overview.html#programming-
tips

借助XML配置和Spring
Integration命名空间的支持,XML解析器隐藏了如何声明目标bean并将它们连接在一起。对于Java和注释配置,了解用于目标最终用户应用程序的framework
API非常重要。

然后我们为此打开一个XSD

<int-redis:queue-inbound-channel-adapter>

 <xsd:element name="queue-inbound-channel-adapter">    <xsd:annotation>        <xsd:documentation> Defines a Message Producing Endpoint for the 'org.springframework.integration.redis.inbound.RedisQueueMessageDrivenEndpoint' for listening a Redis queue.        </xsd:documentation>    </xsd:annotation>

因此,听起来a

int-redis:queue-inbound-channel-adapter
不是
MessageSource
。因此
@InboundChannelAdapter
是死胡同。我同意XML元素的名称当时是错误的,但是重命名它为时已晚。

从这里我们也已经弄清楚我们需要处理这个问题

RedisQueueMessageDrivenEndpoint
。并且由于它是 消息驱动的
,自我管理的,因此我们不需要任何特殊的注释。足以将其声明为如下所示的bean:

@BeanRedisQueueMessageDrivenEndpoint redisQueueMessageDrivenEndpoint(RedisConnectionFactory redisConnectionFactory, RedisSerializer<?> serializer) {    RedisQueueMessageDrivenEndpoint endpoint =     new RedisQueueMessageDrivenEndpoint("archive.post.publication.queue", redisConnectionFactory);    endpoint.setOutputChannelName("postPublicationChannel");    endpoint.setErrorChannelName("postPublicationLoggingChannel");    endpoint.setReceiveTimeout(5000);    endpoint.setSerializer(serializer);    return endpoint;}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/388199.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号