我正在尝试使用glassfish 2.1提供的genericra资源适配器在glassfish中使用activemq。我找到了一些包含有用信息的页面,包括http://activemq.apache.org/sjsas-with-genericjmsra.html。
我实际上已经取得了成功,并且能够让MDB使用activemq作为他们的JMS提供者,但我在尝试进行一些更复杂的配置时遇到了一个问题。我想设置一个主-从配置,这将要求我的客户机使用故障转移的brokerURL:(tcp://broker1:61616,tcp://broker2:61616)。为此,我在调用asadmin create-resource-adapter-config
时设置了以下属性(我必须转义'=‘和':'):
ConnectionFactoryProperties=brokerURL\=failover\:(tcp\://127.0.0.1\:61616,tcp\://127.0.0.1\:61617)
但是,当我的应用程序启动时,我现在得到一个StringIndexOutOfBoundsException。我怀疑两个URL之间的逗号是罪魁祸首,因为这很好用:
brokerURL\=failover\:(tcp\://127.0.0.1\:61616)
只是想知道以前是否有人处理过这个问题。我还想知道是否有比使用通用资源适配器更好的与glassfish集成的方法。
编辑:我忘记在第二个tcp之后转义冒号,但不幸的是,这并没有解决我看到的问题。
发布于 2011-01-19 04:52:56
最后,我切换到使用由lib/optional目录中的activemq提供的资源适配器。
如果有人对此感兴趣,下面是我使用它的步骤
asadmin create-resource-adapter-config --property ServerUrl=failover\:(tcp\://localhost\:61616,tcp\://localhost\:61617) activemqra
asadmin deploy --name activemqra <path to activemq-rar-5.4.2.rar>
然后创建资源:
asadmin create-connector-connection-pool --raname --connectiondefinition javax.jms.ConnectionFactory --transactionsupport XATransaction jms/MyQueueFactoryPool
asadmin create-connector-resource --poolname jms/MyQueueFactoryPool jms/MyQueueQFactory
asadmin create-admin-object --raname activemqra --restype javax.jms.Queue --property PhysicalName=MyQueue jms/MyQueue
要连接mdb,我必须在sun-ejb-jar.xml文件中添加以下内容
<mdb-resource-adapter>
<resource-adapter-mid>activemqra</resource-adapter-mid>
<activation-config>
<activation-config-property>
<activation-config-property-name>DestinationType
</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue
</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destination
</activation-config-property-name>
<activation-config-property-value>MyQueue
</activation-config-property-value>
</activation-config-property>
</activation-config>
</mdb-resource-adapter>
要将其连接到spring JMSTemplate:
<bean id="ConFac" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>jms/MyQueueQQFactory</value>
</property>
<property name="resourceRef">
<value>true</value>
</property>
</bean>
<bean id="myqueue" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>jms/MyQueue</value>
</property>
<property name="resourceRef">
<value>true</value>
</property>
</bean>
<bean id="mdbTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="conFac" />
<property name="defaultDestination" ref="myqueue" />
</bean>
发布于 2012-07-04 20:30:44
这是genericjmsra中的一个已知缺陷,请参阅:http://java.net/jira/browse/GENERICJMSRA-50
在评论中,建议对ObjectBuilder.java进行修复。
发布于 2011-01-17 12:20:19
我看起来你不是在转义第二个uri中的冒号。
https://stackoverflow.com/questions/4696814
复制相似问题