【问题标题】:Issue with STOMP on ActiveMQ being used on OSGI (KARAF)在 OSGI (KARAF) 上使用 ActiveMQ 上的 STOMP 问题
【发布时间】:2012-04-28 19:03:59
【问题描述】:

我已经在 Ubuntu Linux 10.04 上安装了 Karaf (2.2.5)。 在 Karaf 之上安装了 ActiveMQ 作为功能。 使用 stomp 连接器创建了一个自定义代理。 现在,当我尝试从 Java 客户端连接到这个 stomp 代理时,我得到“java.net.SocketTimeoutException: Read timed out”

如果我将 ActiveMQ 作为独立应用程序启动,则相同的客户端可以正常工作。

提前致谢

这是我的配置:

<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:amq="http://activemq.apache.org/schema/core"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:osgi="http://www.springframework.org/schema/osgi"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd   
  http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
  http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="dios" dataDirectory="${karaf.data}/activemq/dios" useShutdownHook="false">
        <destinationPolicy>
            <policyMap>
              <policyEntries>
                <policyEntry topic=">" producerFlowControl="true" memoryLimit="1mb">
                  <pendingSubscriberPolicy>
                    <vmCursor />
                  </pendingSubscriberPolicy>
                </policyEntry>
                <policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb">
                </policyEntry>
              </policyEntries>
            </policyMap>
        </destinationPolicy> 
        <managementContext>
            <managementContext createConnector="false"/>
        </managementContext>
        <persistenceAdapter>
            <kahaDB directory="${karaf.data}/activemq/dios/kahadb"/>
        </persistenceAdapter>
        <shutdownHooks>
           <bean xmlns="http://www.springframework.org/schema/beans" id="hook" class="org.apache.activemq.hooks.SpringContextHook" />
        </shutdownHooks>
        <transportConnectors>
            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
            <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?trace=true"/>
        </transportConnectors>
    </broker>
    <bean id="activemqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://0.0.0.0:61616" />
    </bean>
    <bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
        <property name="maxConnections" value="8" />
        <property name="connectionFactory" ref="activemqConnectionFactory" />
    </bean>
    <bean id="resourceManager" class="org.apache.activemq.pool.ActiveMQResourceManager" init-method="recoverResource">
          <property name="transactionManager" ref="transactionManager" />
          <property name="connectionFactory" ref="activemqConnectionFactory" />
          <property name="resourceName" value="activemq.dios" />
    </bean>
    <osgi:reference id="transactionManager" interface="javax.transaction.TransactionManager" />
    <osgi:service ref="pooledConnectionFactory">
        <osgi:interfaces>
            <value>javax.jms.ConnectionFactory</value>
        </osgi:interfaces>
        <osgi:service-properties>
            <entry key="name" value="dios"/>
        </osgi:service-properties>
    </osgi:service>
</beans>

【问题讨论】:

  • 谁能帮忙??我被困在这里了!!
  • 你能把你的代理配置放在这里吗?如果人们不理解这个问题,他们将无能为力。

标签: activemq stomp apache-karaf


【解决方案1】:

我看不出您的配置有明显问题...就我个人而言,我已经停止在 OSGi 中使用 Spring,因为我一直遇到启动时竞争条件。 Spring 的&lt;osgi:service&gt; 使用超时,因此启动延迟会使一切变得混乱。在 Karaf 2.2.4 下,以下替代方法对我来说效果很好:

  • 将此存储库添加到我的 etc/org.apache.karaf.features.cfg 文件中:mvn:org.apache.activemq/activemq-karaf/${activemq.version}/xml/features
  • 添加一个通过蓝图编写的 etc/activemq-broker.xml 文件。我从 an example XML from Talend 开始,并根据我的需要对其进行了定制。
  • 在我自己的 features.xml 文件中声明对 activemq-blueprint 的依赖,如下所示:&lt;feature version="${activemq.version}"&gt;activemq-blueprint&lt;/feature&gt;
  • 在我的 features.xml 中声明那个 XML 文件:&lt;bundle&gt;blueprint:file:etc/activemq-broker.xml&lt;/bundle&gt;

总的来说,我不是 Blueprint 的忠实粉丝,但它让我的配置变得非常简单。

【讨论】:

    猜你喜欢
    • 2019-03-12
    • 2011-05-29
    • 2016-07-13
    • 2014-09-01
    • 1970-01-01
    • 2016-01-27
    • 2015-12-13
    • 2015-07-08
    • 2014-04-19
    相关资源
    最近更新 更多