Saturday, August 6, 2016

Configuring JMS Synchronous invocation (Dual Channel HTTP-to-JMS) with WSO2 ESB and WebLogic Server Cluster.


This article provides the configuration details and the proxy service samples to connect the ESB as a dual channel HTTP to JMS scenario with WeblLogic Message Queues in a Weblogic cluster. 
Please find the high level architecture related to the scenario in below diagram.
 
Article includes following sections:
  1. Setting up the WebLogic Server
  2. Creating a new WebLogic domain
  3. Administration Server, the Managed Servers, Clusters and Machines configurations
  4. Starting the WebLogic Cluster
  5. Configuring JMS Servers in WebLogic Cluster
  6. Configuring JMS Module, JMS Queue and Connection Factory.
  7. Configuring WSO2 ESB 

This sample is tested with WSO2 ESB 4.9.0, WebLogic 12.1.3, JDK 1.7 and Ubuntu 15.04 environment. 

1. Setting up the WebLogic Server


In order to setup Weblogic 12.1.3 you may download it from the below link.
   
Once you download the generic installer you will receive a jar named – fmw_12.1.3.0.0_wls.jar. Copy that to a specific folder and name the folder as weblogic_home to make it as a location for the installation during the installation. Then using the terminal execute the below command.

            java -jar fmw_12.1.3.0.0_wls.jar


The following screen-shots will provide you installation instructions in order to install the WebLogic server. 

 







  

  


2. Creating a new WebLogic domain


  

 





3. Administration Server, the Managed Servers, Clusters and Machines configurations 


On the Select Optional Configuration screen, select the Administration Server and the Managed Servers, Clusters and Machines options.


On the Configure the Administration Server screen, specify the configuration details for the Administration Server. 


 
On the Configure Managed Servers screen, add managed servers and specify the settings for them. Make sure you specify the actual IP address of the physical machine where you want to host a managed server that is being added. In here we have used only one machine and two ports.

 
On the Configure Clusters screen, add a new cluster and then configure the settings for it.
  

On the Assign Servers to Clusters screen, move the managed servers in the left pane to the right pane, thus assigning them to the cluster.



On the Configure Machines screen, add the machines that will host the managed servers.

 
On the Assign Servers to Machines screen, assign the Administration Server and managed servers in the left pane to the appropriate machines in the right pan.

 

On the Configuration Summary screen, look through the summary of the settings chosen in the wizard and then, if everything is OK, click Create to start the process of domain creation.

 

 

4. Starting the WebLogic Cluster

Start the Administration Server with the startWebLogic.sh script located in the root directory of your domain. After a successful start the terminal will be look as below:
 

  • To access the Administration Console, point your browser to the following address: http://your_domain_host_IP_address:7001/console
  • Navigate to the WL_HOME\server\bin directory and launch the startNodeManager.sh script to start the node manager.
  • Before going any further, make sure that the node managers you just started are reachable. To do that, in the Administration Console, check the Your_Domain->Environment->Machines->Machine_->Monitoring page for each machine.
  • To avoid SSL communication problems, you may use a plain connection to interact with the node manager, which is recommended for testing and development purposes. To do this, you need to edit the WL_HOME/common/nodemanager/nodemanager.properties file, setting the SecureListener property to false. Also be sure to edit the node manager settings in the Administration Console, setting the Type field to Plain in the Machine_->Node Manager tab.
  • Once the status of the node manager for each machine is reachable, you can start the managed servers. In the Administration Console, move to the Your_Domain->Environment->Servers->Control page. Select all the managed servers in the Servers table and then click the Start button.
Before going to the next configurations, please find the high level view of the JMSServer, ConnectionFactory and Message Queue configuration below. 
Follow the below steps to create the JMSServer, JMS Modules, ConnectionFactory and Message Queue on the WebLogic cluster.

5. Configure JMS Servers in WebLogic Cluster.

Login to WebLogic management console using the credentials.









Repeat the same above steps to created the JMSServer-2 and after creating both JMSServer the Summary of JMS Servers will look like below:




6. Configure JMS Module, JMS Queue and Connection Factory.
 
Go to Domain Structure → base_domain → Services → Messaging → JMS Modules and create a new module and follow the screens below.








Repeat the same steps to create the System Module 2 as well and summery of JMS Modules will appear as below:




Then Select the created JMS Module, here it is SystemModule1 and select the tab Subdeployments. Then follow the below screens.





Create the same sub-deployment folder to both servers and add the Jms server 2 and managed server 2 also as the targets.




Select the Module created ( SystemModule1 ) and follow the screens to create the connection factory.
 






Repeat the same steps above and create another connection factory to system module 2 as below:


 
 
Same way to create the queues. Follow the screens as below:
 




You need to create two queues per system module as below:

Repeat the same steps to create queues in system module 2 as well and the summery of system module 2 will look like below:



That is the end of WebLogic side configurations. 

7. Configuring WSO2 ESB

Firstly, you need to create the client jar of WebLogic server to support the WSO2 ESB. Go to /home/ubuntu/Oracle/Middleware/O_H/wlserver/server/lib and run the below command.

java -jar wljarbuilder.jar


This will create a wlfullclient.jar inside the same location. Now you need to remove the javax.jms package and javax.xml.namespace package from the wlfullclient.jar.


In order to achieve this you can follow below two options.

  •   Use the pom.xml in the https://docs.wso2.com/display/ESB490/Configure+with+WebLogic and build the bundle and copied it to ESB_HOME/repository/components/dropins.
  •   Open the wlfullclient.jar using Archive Manager and remove the folders of the below packages manually.
                                 javax.jms
                                 javax.xml.namespace
                                 And copy the jar to ESB_HOME/repository/components/lib.


JMS Listener configuration in axis2.xml


<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">

<parameter name="myQueueConnectionFactory" locked="false">
<parameter name="java.naming.factory.initial" locked="false">weblogic.jndi.WLInitialContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">t3://172.22.217.135:7007</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">jms/TestConnectionFactory1</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
<parameter name="transport.jms.UserName" locked="false">weblogic</parameter>
<parameter name="transport.jms.Password" locked="false">1qaz2wsx@</parameter>
</parameter>

<parameter name="myQueueConnectionFactory1" locked="false">
<parameter name="java.naming.factory.initial" locked="false">weblogic.jndi.WLInitialContextFactory</parameter>
<parameter name="java.naming.provider.url" locked="false">t3://172.22.217.135:7005</parameter>
<parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">jms/TestConnectionFactory1</parameter>
<parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
<parameter name="transport.jms.UserName" locked="false">weblogic</parameter>
<parameter name="transport.jms.Password" locked="false">1qaz2wsx@</parameter>
</parameter>

</transportReceiver>

JMS Sender configuration in axis2.xml

<transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/>

Consumer Proxy Service 1

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="WeblogicJMSConsumerProxy1"
       transports="jms"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <log level="custom">
            <property name="STATUS:"
                      value="------Message Consumed by WeblogicJMSConsumerProxy1--------"/>
         </log>
         <log level="full"/>
         <property name="Accept-Encoding" scope="transport" action="remove"/>
         <property name="Content-Length" scope="transport" action="remove"/>
         <property name="Content-Type" scope="transport" action="remove"/>
         <property name="User-Agent" scope="transport" action="remove"/>
         <log level="custom">
            <property name="STATUS:"
                      value="------Message Sent by WeblogicJMSConsumerProxy1--------"/>
         </log>
         <property name="OUT_ONLY" value="true"/>
         <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
         <send>
            <endpoint>
               <address uri="jms:/jms/TestQueue2?transport.jms.ConnectionFactoryJNDIName=jms/TestConnectionFactory1&amp;java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory&amp;java.naming.provider.url=t3://172.22.217.135:7007&amp;transport.jms.DestinationType=queue"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <parameter name="transport.jms.ContentType">
      <rules>
         <jmsProperty>contentType</jmsProperty>
         <default>application/xml</default>
      </rules>
   </parameter>
   <parameter name="transport.jms.ConnectionFactory">myQueueConnectionFactory</parameter>
   <parameter name="transport.jms.Destination">jms/TestQueue1</parameter>
   <description/>
</proxy>

 Consumer Proxy Service 2

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="WeblogicJMSConsumerProxy2"
       transports="jms"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <log level="custom">
            <property name="STATUS:"
                      value="------Message Consumed by WeblogicJMSConsumerProxy2--------"/>
         </log>
         <log level="full"/>
         <property name="Accept-Encoding" scope="transport" action="remove"/>
         <property name="Content-Length" scope="transport" action="remove"/>
         <property name="Content-Type" scope="transport" action="remove"/>
         <property name="User-Agent" scope="transport" action="remove"/>
         <log level="custom">
            <property name="STATUS:"
                      value="------Message Sent by WeblogicJMSConsumerProxy--------"/>
         </log>
         <property name="OUT_ONLY" value="true"/>
         <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
         <send>
            <endpoint>
               <address uri="jms:/jms/TestQueue2?transport.jms.ConnectionFactoryJNDIName=jms/TestConnectionFactory1&amp;java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory&amp;java.naming.provider.url=t3://172.22.217.135:7005&amp;transport.jms.DestinationType=queue"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <parameter name="transport.jms.ContentType">
      <rules>
         <jmsProperty>contentType</jmsProperty>
         <default>application/xml</default>
      </rules>
   </parameter>
   <parameter name="transport.jms.ConnectionFactory">myQueueConnectionFactory1</parameter>
   <parameter name="transport.jms.Destination">jms/TestQueue1</parameter>
   <description/>
</proxy>

 Producer Proxy Service

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="WeblogicJMSSenderProxy"
       transports="http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="Accept-Encoding" scope="transport" action="remove"/>
         <property name="Content-Length" scope="transport" action="remove"/>
         <property name="Content-Type" scope="transport" action="remove"/>
         <property name="User-Agent" scope="transport" action="remove"/>
         <log level="custom">
            <property name="STATUS:"
                      value="------Message Sent by WeblogicJMSConsumerProxy--------"/>
         </log>
         <send>
            <endpoint>
               <loadbalance algorithm="org.apache.synapse.endpoints.algorithms.RoundRobin">
                  <endpoint>
                     <address uri="jms:/jms/TestQueue1?transport.jms.ConnectionFactoryJNDIName=jms/TestConnectionFactory1&amp;java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory&amp;java.naming.provider.url=t3://172.22.217.135:7007&amp;transport.jms.DestinationType=queue&amp;transport.jms.ReplyDestination=jms/TestQueue2&amp;transport.jms.ContentTypeProperty=JMSContentType"/>
                  </endpoint>
                  <endpoint>
                     <address uri="jms:/jms/TestQueue1?transport.jms.ConnectionFactoryJNDIName=jms/TestConnectionFactory1&amp;java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory&amp;java.naming.provider.url=t3://172.22.217.135:7005&amp;transport.jms.DestinationType=queue&amp;transport.jms.ReplyDestination=jms/TestQueue2&amp;transport.jms.ContentTypeProperty=JMSContentType"/>
                  </endpoint>
               </loadbalance>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <log level="custom">
            <property name="STATUS:"
                      value="------------------Out sequence invoked---------------------"/>
         </log>
         <log level="full"/>
         <log level="custom">
            <property name="STATUS:"
                      value="------------------Out sequence invoked before setting content type--------------------"/>
         </log>
         <send/>
      </outSequence>
   </target>
   <parameter name="transport.jms.ContentType">
      <rules>
         <jmsProperty>JMSContentType</jmsProperty>
         <default>application/xml</default>
      </rules>
   </parameter>
   <description/>
</proxy>

 Test Results


References

[1] http://www.oracle.com/technetwork/articles/soa/vasiliev-wls-cluster-1867166.html

[2] https://docs.wso2.com/display/ESB490/Configure+with+WebLogic

[3] http://ajanthane.blogspot.com/2016/05/configuring-wso2-esb-with-weblogic.html

[4] http://markchensblog.blogspot.com/2013/02/configure-weblogic-jms-resources.html