Problem using genericra to integrate activemq and glassfish when using failover protocol

I am trying to use activemq in a glassfish using a genericra resource adapter equipped with 2.1 glass. I found several pages with useful information, including http://activemq.apache.org/sjsas-with-genericjmsra.html .

I really had success, and I managed to get MDB to use activemq as the JMS provider, but I ran into a problem as I try to complete a more complex configuration. I want to configure a master-slave configuration, which will require my clients to use the URL broker to switch to the backup resource: (tcp: // broker1: 61616, tcp: // broker2: 61616). To do this, I set the following property when calling asadmin create-resource-adapter-config(I need to hide '=' and ':'):

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

However, now I get a StringIndexOutOfBoundsException exception when my application starts. I suspect that the comma between the two URLs is the culprit, as this works fine:

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

It’s just interesting if someone had considered this question before. It's also interesting to know if there is a better way to integrate with glass fish than using a common resource adapter.

EDIT: I forgot to avoid the colon after the second tcp, but unfortunately this did not fix the problem that I see.

+3
source share
3 answers

In the end, I switched to using the resource adapter provided by activemq, which is in the lib / optional directory.

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

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 the 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 connect mdb, I had to add this to 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 associate this with 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>
+3
source

genericjmsra, .: http://java.net/jira/browse/GENERICJMSRA-50

ObjectBuilder.java.

+1

It looks like you are not avoiding the colon in the second uri.

0
source

Source: https://habr.com/ru/post/1785556/


All Articles