- Patch the ActiveMQ jars
- Patch Weblogic JMS jar
- Install the resource adapter into Weblogic 12c.
- Plugin runtime system parameters to enable JMX connection from the ActiveMQ console
- Deploy the ActiveMQ Console web app
1. Patch the ActiveMQ jars
Weblogic is expecting an ra.xml configuration file describing the resource adapter instantiation parameters and the connection factories definitions. The factories definitions included therein are abstract. They do not refer to any instantiation parameters.
The only instantiation parameters are those of the resource adapter described by the sequence of config-property elements
Download here a sample of a correct resource adapter configuration file.
Our factory definition have to include the following interfaces, classes :
- managedconnectionfactory-class
- connectionfactory-interface
- connection-interface
- connection-impl-clas
The relative xml configuration looks like this:
<connection-definition>
<managedconnectionfactory class>
org.apache.activemq.ra.ActiveMQManagedConnectionFactory
</managedconnectionfactory-class>
<connectionfactory-interface>
javax.jms.ConnectionFactory
</connectionfactory-interface>
<connectionfactory-impl-class>
org.apache.activemq.ra.ActiveMQConnectionFactory
</connectionfactory-impl-class>
<connection-interface>
javax.jms.Connection
</connection-interface>
<connection-impl-class>
org.apache.activemq.ra.ManagedConnectionProxy
</connection-impl-class>
</connection-definition>
The cascade of instantiation is better described by this class diagram (figure 1):
Figure 1
However
in our case, Weblogic expects an XASession and hence we to produce and
XAConnection that will produce that XASession.. Regardless of your
setting, the ActiveMQManagedConnectionFactory by default does not instantiate such classes, hence we have to force it. We have patched this class to force it to produce an ActiveMQXAConnectionFactory. The following
diagram better described the instantiation cascade (figure 2):
Figure 2
Patch activemq-ra-5.11.1.jar with the modified class org.apache.activemq.ra.ActiveMQManagedConnectionFactory. Make sure the jar inside the rar archive are copied again into the lib directory of the Weblogic domain.
Instances created by these factories need to be specified in weblogic-ra.xml. Most important the connection factory defined therein must match a defintion found in ra.xml.
In additoin, we need to define our instance and their JNDI names under which they will they will referenced under the Weblogic JNDI tree:
<weblogic-connector xmlns="http://xmlns.oracle.com/weblogic/weblogic-connector"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-connector
http://xmlns.oracle.com/weblogic/weblogic-connector/1.0/weblogic-connector.xsd">
<jndi-name>ResourceAdapter
<enable-access-outside-app>truexmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-connector
http://xmlns.oracle.com/weblogic/weblogic-connector/1.0/weblogic-connector.xsd">
<jndi-name>ResourceAdapter
<enable-global-access-to-classes>true
<admin-objects>
<admin-object-group>
<admin-object-interface>
javax.jms.Queue
</admin-object-interface>
<!--admin-object-class>
org.apache.activemq.command.ActiveMQQueue
</admin-object-class-->
<admin-object-class>
org.apache.activemq.command.ActiveMQQueue
</admin-object-class>
<admin-object-instance>
<jndi-name>jms/queue/MyEvent</jndi->
<properties>
<property>
<name>PhysicalName</name> <value>MyEvent</value>
</property>
</properties>
</admin-object-instance>
</admin-object-group>
</admin-objects>
<outbound-resource-adapter>
<connection-definition-group>
<connection-factory-interface>javax.jms.ConnectionFactory>
<connection-instance>
<jndi-name>ConnectionFactory</jndi-name>
<connection-properties>
<pool-params>
<initial-capacity>1</initial-capacity>
<max-capacity>20</max-capacity>
<capacity-increment>1<<capacity-increment>
</pool-params>
</connection-properties>
</connection-instance>
</connection-definition-group>
</outbound-resource-adapter>
</weblogic-connector>
Download here a correct configuration of weblogic-ra.xml
2. Patch the Weblogic jar
Unfortunately the recovery of the connection destination carried out by the weblogic container casts for some reason the JMS destination to weblogic.jms.common.DestinationImpl. Hence, it prevents plugging in foreign broker into Weblogic.
To overcome this, it is up to you to inherit the ActiveMQDestination directly from the weblogic DestinationImpl.
I ended up with the following classes structure:
Figure 3
Create a jar file com.oracle.weblogic.jms _patch.jar containing the mofied class weblogic.jms.common.DestinationImpl.
In the command bat file starting the managed server where ActiveMQ is going to be hosted, add the patch to the PRE_CLASSPATH:
SET ACTIVEMQ=[activeMQ directory]
SET PRE_CLASSPATH=%PRE_CLASSPATH%;%ACTIVEMQ%\com.oracle.weblogic.jms _patch.jar;
Patch jar activemq-client-5.11.1.jar with the modified class org.apache.activemq.jndi.JNDIBaseStorable
Make sure the jar inside the rar archive are copied again into the lib directory of the domain.
3. Install the resource adapter into Weblogic 12c.
Make sure both the resource adapter configuration files, ra.xml and weblogic-ra,xml lie under META-INF. Deploy the rar archive as an application to Weblogic.
4. Plugin runtime system parameters to enable JMX connection from the ActiveMQ console
To enable JMX connection please input in the JVM startup the following parameters (this will added to the environment variable JAVA_OPTIONS)
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder
To instruct the ActiveMQ console to which broker to connect to you need to set system properties into the JVM on which the web console in running. In our case, as we are dealing with in-memory broker, it is the same JVM of the same managed server the broker is running onto.
Hence we will add the following parameters to our JVM:
-Dwebconsole.type=properties -Dwebconsole.jms.url=vm://localhost -Dwebconsole.jmx.url=service:jmx:rmi:///jndi/rmi://localhost:9010/jmxrmi (this will added to the environment variable JAVA_OPTIONS)
5. Deploy the ActiveMQ Console webapp
Deploy the activemq-web-console-5.11.1.war to the same Managed server where the in memory broker resides.



