使用故障转移协议时,使用genericra集成activemq和glassfish时出现问题

使用故障转移协议时,使用genericra集成activemq和glassfish时出现问题,glassfish,jms,activemq,high-availability,generic-jms-ra,Glassfish,Jms,Activemq,High Availability,Generic Jms Ra,我正在尝试使用glassfish 2.1提供的genericra资源适配器在glassfish中使用activemq。我发现了一些有用的信息,包括 事实上,我已经取得了成功,并且能够让MDB使用activemq作为他们的JMS提供程序,但是我在尝试进行一些更复杂的配置时遇到了一个问题。我想设置一个主从配置,这将要求我的客户端使用故障切换的代理:(tcp://broker1:61616,tcp://broker2:61616). 为此,我在调用asadmincreate resource adap

我正在尝试使用glassfish 2.1提供的genericra资源适配器在glassfish中使用activemq。我发现了一些有用的信息,包括

事实上,我已经取得了成功,并且能够让MDB使用activemq作为他们的JMS提供程序,但是我在尝试进行一些更复杂的配置时遇到了一个问题。我想设置一个主从配置,这将要求我的客户端使用故障切换的代理:(tcp://broker1:61616,tcp://broker2:61616). 为此,我在调用asadmin
create resource adapter config
时设置了以下属性(我必须转义“=”和“:”):

然而,当我的应用程序启动时,我现在得到一个StringIndexOutOfBoundsException。我怀疑两个URL之间的逗号是罪魁祸首,因为这样做很好:

brokerURL\=failover\:(tcp\://127.0.0.1\:61616)
只是想知道以前是否有人处理过这个问题。还想知道是否有比使用通用资源适配器更好的方法与glassfish集成


编辑:我忘记在第二次tcp之后转义冒号,但不幸的是,这并没有解决我看到的问题。

我看起来你没有在第二个uri中转义冒号。

我最终切换到使用activemq提供的资源适配器,该适配器位于lib/optional目录中

如果有人对此感兴趣,以下是我为使其工作所遵循的步骤

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>
为了连接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>

activemqra
目的型
javax.jms.Queue
目的地
我的队列
要将其连接到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>

jms/myqueueqfactory
真的
jms/MyQueue
真的

这是genericjmsra中的已知缺陷,请参阅:


在注释中,建议对ObjectBuilder.java进行修复。

谢谢,我没有注意到缺少转义,但不幸的是,这不是问题所在。我还尝试过转义逗号而不是转义逗号。这对我在Glassfish 3中用ActiveMQ替换OpenMQ有所帮助。我们所有的配置都是通过Ant完成的,您概述的asadmin步骤对我们帮助很大。
<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>
<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>