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

发布于 10-12 06:31 字数 877 浏览 9 评论 0原文

我正在尝试使用 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 之后转义冒号,但不幸的是这并没有解决我所看到的问题。

I'm attempting to use activemq in glassfish using the genericra resource adapter provided with glassfish 2.1. I have found a few pages with helpful information including http://activemq.apache.org/sjsas-with-genericjmsra.html.

I have actually had success and been able to get MDBs to use activemq as their JMS provider, but I'm running into an issue as I'm trying to do some more complicated configuration. I want to set up a master-slave configuration, which would require my clients to use a brokerURL of failover:(tcp://broker1:61616,tcp://broker2:61616). In order to do this, I set the following property when calling asadmin create-resource-adapter-config (I have to escape '=' and ':'):

ConnectionFactoryProperties=brokerURL\=failover\:(tcp\://127.0.0.1\:61616,tcp\://127.0.0.1\:61617)

However, I am now getting a StringIndexOutOfBoundsException when my application starts up. I suspect the comma in between the two URLs is the culprit, since this works fine:

brokerURL\=failover\:(tcp\://127.0.0.1\:61616)

Just wondering if anyone has dealt with this issue before. Also wondering if there is a better way to integrate with glassfish than using the generic resource adapter.

EDIT: I forgot to escape the colon after the second tcp, but unfortunately that didn't fix the issue I'm seeing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

燃情2024-10-19 06:31:55

我最终转而使用 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>

I ended up switching to use the resource adapter provided by activemq that comes in the lib/optional directory.

In case anyone is interested, here are the steps I followed to get it working

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>

Then to create resources:

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

To get an mdb hooked up, I had to add this in the 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>

To hook this up to a 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>
坏尐絯2024-10-19 06:31:55

这是 genericjmsra 中的一个已知缺陷,请参阅:http://java.net/jira/browse/GENERICJMSRA -50

在评论中建议在 ObjectBuilder.java 中进行修复。

This is a known defect in genericjmsra, see: http://java.net/jira/browse/GENERICJMSRA-50

In the comments a fix in ObjectBuilder.java is suggested.

梦在夏天2024-10-19 06:31:55

我看起来你没有逃脱第二个 uri 中的冒号。

I looks like you're not escaping the colon in the second uri.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文