我正在使用ActiveMq 5.4.3,並且正在使用隊列。我有我的製作人作爲webservice(而不是Ejb),並且我在jboss服務器中部署了webserice war。我的服務工作正常。但是每當這個服務被稱爲連接並且會話被創建並關閉時。我想克服這個瓶頸,以便在啓動服務器時只創建一次連接和會話。我怎樣才能做到這一點。我不想讓jboss充當mdb容器。我已經部署了ActiveMQ的-RAR的JBoss部署我的文件夾內,並添加了以下子系統使用JNDI PooledConnectionFactory connectionFactory = (PooledConnectionFactory) context.lookupLink("java:jboss/activemq/QueueConnectionFactory");
在jboss中爲Activemq配置池連接jndi 7
<subsystem xmlns="urn:jboss:domain:resource-adapters:1.0">
<resource-adapters>
<resource-adapter>
<archive>
activemq-ra.rar
</archive>
<transaction-support>XATransaction</transaction-support>
<connection-definitions>
<connection-definition class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name="java:jboss/activemq/QueueConnectionFactory" enabled="true" use-java-context="true" pool-name="QueueConnectionFactory" use-ccm="true">
<config-property name="prefill">
false
</config-property>
<config-property name="max-pool-size">
20
</config-property>
<config-property name="ServerUrl">
tcp://localhost
</config-property>
<config-property name="use-strict-min">
false
</config-property>
<config-property name="min-pool-size">
5
</config-property>
</connection-definition>
</connection-definitions>
<admin-objects>
<admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="activemq/queue/outbound" enabled="true" use-java-context="true" pool-name="outbound">
<config-property name="Type">
javax.jms.Queue
</config-property>
<config-property name="Properties">
PhysicalName=queue.outbound
</config-property>
</admin-object>
<admin-object class-name="org.apache.activemq.command.ActiveMQTopic" jndi-name="activemq/topic/inbound" enabled="true" use-java-context="true" pool-name="inbound">
<config-property name="Type">
javax.jms.Topic
</config-property>
<config-property name="Properties">
PhysicalName=topic.inbound
</config-property>
</admin-object>
</admin-objects>
</resource-adapter>
</resource-adapters>
</subsystem>
現在,當我試圖讓連接(下面的代碼)
我得到的錯誤爲
javax.naming.NameNotFoundException: org.apache.activemq.ra.ActiveMQManagedConnectionFactory -- service jboss.naming.context.java."org.apache.activemq.ra.ActiveMQManagedConnectionFactory
THX烏拉圭回合的建議。我已經嘗試了PooledConnectionFactory,但即便如此,每個生產者都在建立連接。我已經使用JNDI做了一些實現,但遇到了一個錯誤。所以我編輯了這個問題併發布了錯誤。 – Muzy 2012-08-08 05:17:02