持久订阅 ActiveMQ

2024-04-24

我正在尝试为我的消息设置持久订阅者,以便即使在服务器重新启动后它们也能保留在主题中。

但在配置过程中我收到与 xml 相关的错误:

这是我的配置 xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:int="http://www.springframework.org/schema/integration"
       xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
       xmlns:oxm="http://www.springframework.org/schema/oxm"
       xmlns:int-jme="http://www.springframework.org/schema/integration"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
                http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
                http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
                http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd">


    <!-- Component scan to find all Spring components -->
    <context:component-scan base-package="com.geekcap.springintegrationexample" />

    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
        <property name="order" value="1" />
        <property name="messageConverters">
            <list>
                <!-- Default converters -->
                <bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
                <bean class="org.springframework.http.converter.FormHttpMessageConverter"/>
                <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
                <bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/>
                <bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter"/>
                <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
            </list>
        </property>
    </bean>

    <!-- Define a channel to communicate out to a JMS Destination -->
    <int:channel id="topicChannel"/>

    <!-- Define the ActiveMQ connection factory -->
    <bean id="connectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://localhost:61616"/>
    </bean>

    <!--
        Define an adaptor that route topicChannel messages to the myTopic topic; the outbound-channel-adapter
        automagically fines the configured connectionFactory bean (by naming convention
      -->
    <int-jms:outbound-channel-adapter channel="topicChannel"
                                      destination-name="topic.myTopic"
                                      pub-sub-domain="true" />

    <!-- Create a channel for a listener that will consume messages-->
    <int:channel id="listenerChannel" />

    <int-jms:message-driven-channel-adapter id="messageDrivenAdapter"
                                            channel="getPayloadChannel"
                                            subscription-durable="true"
                                            durable-subscription-name="myDurableSubscription"
                                            destination-name="topic.myTopic"
                                            pub-sub-domain="true" />

    <int:service-activator input-channel="listenerChannel" ref="messageListenerImpl" method="processMessage" />

    <int:channel id="getPayloadChannel" />

    <int:service-activator input-channel="getPayloadChannel" output-channel="listenerChannel" ref="retrievePayloadServiceImpl" method="getPayload" />

</beans>

But in message-driven-channel-adapter following attributes gives an error: enter image description here

It says:

在这一行找到多个注释:

  • cvc-complex-type.3.2.2:属性“subscription-durable”不允许出现在元素“int-jms:message-driven-channel-”中 适配器'。
  • cvc-complex-type.3.2.2:属性“durable-subscription-name”不允许出现在元素“int-jms:message-driven-channel-”中 适配器'。

但在更多示例中,我可以看到以下属性运行良好。

  • subscription-durable="true"

  • durable-subscription-name="myDurableSubscription"

那我的配置可能有什么问题。

编辑: POM.xml 中的 Spring Integration 依赖项

<!-- Spring Integration -->
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-core</artifactId>
            <version>4.2.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-jms</artifactId>
            <version>4.2.0.RELEASE</version>
        </dependency>

EDIT:

Please see attached image: enter image description here

Also see my log which signifies that target method has been invoked which is supposed to be happened when message has been consumed by client. enter image description here Please help.


您使用什么版本的 Spring Integration? 4 年多前,2.1.0.RELEASE 版本中添加了对持久订阅的支持。

当前版本是4.2.0.RELEASE。

EDIT:

我忘了提及您需要一个客户端 ID 才能进行持久订阅。

您查看了日志消息吗?这看起来很清楚...

14:12:39.557 警告 [jmsIn.container-1][org.springframework.jms.listener.DefaultMessageListenerContainer] 目标“topic://topic.demo”的 JMS 消息侦听器调用程序设置失败 - 尝试恢复。原因:如果不在连接上指定唯一的 clientID,则无法创建持久订阅者

将 clientId 添加到您的连接工厂...

    <property name="clientId" value="myClient"/>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

持久订阅 ActiveMQ 的相关文章

随机推荐

  • 通过引用传递值是否会显着提高速度? [复制]

    这个问题在这里已经有答案了 可能的重复 按值传递与按引用传递性能 C net https stackoverflow com questions 3395873 pass by value vs pass by reference perf
  • 当应用程序处于后台时,React Native setInterval 会暂停

    我正在开发一个反应本机应用程序 对于其中一项任务 我需要使用 javascriptsetInterval功能 但当应用程序处于后台时它会停止 谁能指导我 为什么它停止了 有什么办法解决吗 My Code let startTimer set
  • 使用 PHP 的论坛 [关闭]

    Closed 此问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我想使用 Php 设计一个论坛 但我面临的问题是我不知道如何在其中放置帖子创建者 据我所知 诸如所见即所
  • Excel IF函数大于x但小于y

    我正在尝试安排一列 以便基本上可以对结果进行 评分 我正在寻找一个公式 该公式将 如果大于 100000 但小于 110000 10 如果大于 90000 但小于 99999 9等等 有人可以帮忙吗 我们可以将 LOOKUP 与范围一起使用
  • XPage:处理浏览器后退按钮

    我为 Notes 表单创建了一个 XPage 我添加了一个编辑按钮 用于执行一些逻辑 然后将文档模式切换为 编辑 以及一个保存并关闭按钮 用于保存文档并重定向到 Notes 视图的 XPage 这工作正常 但是当返回视图后按下浏览器后退按钮
  • Hudson 和 maven-release-plugin

    我正在使用 Hudsonmaven 发布 插件 http maven apache org plugins maven release plugin 如您所知 maven release plugin 构建项目分两步 release pre
  • 使用 matplotlib 绘制亚像素精度散点图?

    注 我在写这个问题时找到了解决方案 我的回答如下 有没有一种简单的方法可以使用 matplotlib 获得圆的亚像素抗锯齿放置 我能够创建以下 gif 但圆圈的运动以整数像素为单位这一事实确实困扰着我 我当然可以渲染一个大图像 plt sa
  • 当 Button.CommandProperty 为 null 时如何禁用按钮

    简短说明 Button CommandProperty 绑定到 ViewModel 的 SomeObject SomeCommand 属性 当 SomeObject 的 SomeCommand 属性设置为 null 或整个 SomeObje
  • 如何从 url 中提取 &client= ? [复制]

    这个问题在这里已经有答案了 如果我的网址是http link ads blogspot com url http could be any url com name 123456789101112 using 纯JavaScript我该如何
  • PhotoChooserTask 后未触发 ApplicationBar 图标按钮单击事件

    我无法在某些条件下触发 ApplicationBarIconButton 的单击事件 我尝试简化重现它所需的步骤 1 创建一个新的Windows Phone应用程序 2 添加新页面 Page1 xaml 3 在 MainPage xaml
  • 如何获取 TeamCity Build 触发器过滤器来构建功能分支而不是默认分支

    我创建了一个 Team City 构建来构建功能分支 默认分支 refs heads development 分支规范 refs heads feature 我有一个 vcs 触发器 因此它会为每次 git 推送而构建 但我不希望它在有人推
  • 如何使用 JavaScript 检查按钮是否被点击

    有没有一种简单的方法可以沿着这些思路做一些事情 JavaScript if document getElementById button clicked true alert button was clicked HTML
  • 将glm四元数转换为旋转矩阵并与opengl一起使用

    所以我将对象的方向存储在 glm fquat 中 我想用它来旋转我的模型 我怎么做 我试过这个 glPushMatrix glTranslatef position x position y position z glMultMatrixf
  • 编译器可以将函数范围的、非静态的 const 数组存储在常量数据中并避免每次调用初始化吗?

    读书中字符数组 字符串如何存储在二进制文件 C C 中 https stackoverflow com q 71932148 364696 我在思考原始字符串涉及的各种方式 Nancy 将在生成的二进制文件中完好无损地显示 那个帖子的案例是
  • 文件类型 .pl 关联并使用 cmd.exe 运行脚本

    我创建了一个新的文件类型 pl 资源管理器 gt 工具 gt 文件夹选项 gt 文件类型 现在我想创建一个新的操作 它将调用 cmd exe 并自动运行 PERL 脚本 我不知道在 用于执行操作的应用程序 下要写什么 我必须向 cmd ex
  • 在 R 中将 NA 设置为 0

    将一个数据帧与另一个数据帧合并后 偶尔会留下随机的 NA 我想将这些 NA 设置为 0 以便我可以用它们执行计算 我正在尝试这样做 bothbeams data within bothbeams data bothbeams data x
  • NSMutableArray 不添加对象[重复]

    这个问题在这里已经有答案了 我认为 我犯了一个非常基本的错误 但我正在使用NSMutableArray这不知何故并没有添加对象 我正在按其方式发送它 我有一个属性 并合成 property nonatomic strong NSMutabl
  • 如何惯用地复制切片?

    在 Go 中 复制切片是标准操作 如下所示 It will figure out the details to match slice sizes dst copy dst n src m 在 Rust 中 我找不到类似的替换方法 我想出的
  • 如何将 ActiveRecord 模型属性从 json 迁移到 jsonb?

    迁移应该是什么样子 我想利用 jsonb 数组查询技术 我会这样写迁移 def change reversible do dir dir up change column models attribute jsonb USING CAST
  • 持久订阅 ActiveMQ

    我正在尝试为我的消息设置持久订阅者 以便即使在服务器重新启动后它们也能保留在主题中 但在配置过程中我收到与 xml 相关的错误 这是我的配置 xml