Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 持久订阅ActiveMQ_Java_Jms_Activemq_Spring Integration_Durable Subscription - Fatal编程技术网

Java 持久订阅ActiveMQ

Java 持久订阅ActiveMQ,java,jms,activemq,spring-integration,durable-subscription,Java,Jms,Activemq,Spring Integration,Durable Subscription,我正在尝试为我的消息设置持久订户,以便即使在服务器重新启动后,它们也能在主题中持久化 但在配置过程中,我遇到了与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"

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

但在配置过程中,我遇到了与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>
编辑:

请参阅附图:

另请参阅我的日志,它表示目标方法已被调用,这应该是在客户端使用消息时发生的。
请帮忙

您使用的是哪个版本的Spring Integration?对持久订阅的支持在4年前的版本2.1.0.RELEASE中添加

当前版本为4.2.0.0版本

编辑

我忘了提一下,持久订阅需要客户端id

你看了日志信息了吗?这似乎很清楚

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

将clientId添加到连接工厂

    <property name="clientId" value="myClient"/>


检查DTD是否支持这些功能attributes@Saravana谢谢你的快速回复。但我不熟悉XML操作,也不知道如何操作。你能帮我一下吗?@Vihar你能帮我一下吗?我只使用4.2.0.RELEASE我也很好奇,因为spring文档本身在这里提到了这一点,我更新了这个问题,添加了pom.xmlOh中使用的spring集成依赖项-看起来你没有使用spring感知IDE(STS、IDEA等);错误只出现在IDE中,在运行时它是正常的。基本eclipse不知道如何找到正确的模式。我们通常建议使用无版本架构,但如果您不能使用支持spring的IDE,请将该版本添加到架构-
spring-integration-jms-4.2.xsd
-您也不应该使用旧的核心spring架构(2.5).我刚才添加了您提到的模式,前面的错误消失了,但现在又出现了一个错误,
引用的文件包含错误(http://www.springframework.org/schema/integration/spring-integration-4.2.xsd). 有关详细信息,请右键单击问题视图中的消息,然后选择“显示详细信息…”
    <property name="clientId" value="myClient"/>