0

Ubuntu Linux 10.04 に Karaf (2.2.5) をインストールしました。Karaf の上に機能として ActiveMQ をインストールしました。ストンプ コネクタを使用してカスタム ブローカーを作成しました。Java クライアントからこのストンプ ブローカーに接続しようとすると、「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>
4

1 に答える 1

0

あなたの設定に明らかな問題は見当たりません... 個人的には、起動時の競合状態に遭遇し続けたため、OSGi で Spring を使用するのをやめました。Spring<osgi:service>はタイムアウトを使用するため、起動が遅れるとすべてが台無しになります。次の代替アプローチは、Karaf 2.2.4 で非常にうまく機能しました。

  • このリポジトリを etc/org.apache.karaf.features.cfg ファイルに追加します。mvn:org.apache.activemq/activemq-karaf/${activemq.version}/xml/features
  • ブループリント経由で作成された etc/activemq-broker.xml ファイルを追加します。Talend のサンプル XML から始めて、自分のニーズに合わせてカスタマイズしました。
  • 次のように、自分の features.xml ファイルで activemq-blueprint への依存関係を宣言します。<feature version="${activemq.version}">activemq-blueprint</feature>
  • features.xml でその XML ファイルを宣言します。<bundle>blueprint:file:etc/activemq-broker.xml</bundle>

私は一般的にブループリントの大ファンではありませんが、この構成は非常に簡単でした。

于 2012-04-20T12:48:50.350 に答える