This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Integrating with Oracle Weblogic Server
In the sections that follow, we will look at how web applications deployed in Oracle Weblogic Server can communicate with WSO2 Message Broker (WSO2 MB) as JMS subscribers and JMS publishers.
Setting up Oracle Weblogic Server and WSO2 MB
Note that these instructions have been tested with Weblogics server 12.1.2.
Follow the steps given below to set up Oracle Weblogic Server
- Download Oracle Weblogics server 12.1.2 from here.
- Follow the instructions given in the
README.txt
file to install and start the server.
Developing a web application (JMS Subscriber/Publisher)
To create a web application that can subscribe/publish to a queue or topic in WSO2 MB, you will need to write a JMS client (subscriber/publisher) and build it as a web application (WAR file), which can be deployed in the application server.
Follow the steps given below to build a web application that can subscribe and publish to a queue in WSO2 MB.
Step 1: Writing the JMS client
First, we will write a JMS client that subscribes to a queue in WSO2 MB: Create a java project using the source files given below and compile it.
Once you build the above client, you will have the following class files:
- JmsQueue.class
- SampleQueueReceiver.class
- SampleQueueSender.class
Step 2: Building the web application
Now, let's build a web application using the source files (JMS client) given above. This web application will also have an interface for invoking the JMS client. Follow the steps given below.
Create a folder structure in your local machine by following the steps given below.
Create the following folder structure in your local machine:
-WebApp/ -WEB-INF/ -lib/ -classes/ -MyPackage/ -web.xml Index.html
And the class files you developed in step1 to the
WEB-INF/lib/classes/MyPackage
directory. You can download these class files from here.Update the
web.xml
file with the following content:<?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>JMS Queue Sample Web Application</display-name> <description> This is a sample web application which sends and receives queue message using wso2 message broker. </description> <servlet> <servlet-name>JMSQueueServlet</servlet-name> <servlet-class>mypackage.JmsQueue</servlet-class> </servlet> <servlet-mapping> <servlet-name>JMSQueueServlet</servlet-name> <url-pattern>/jmsqueue</url-pattern> </servlet-mapping> </web-app>
- Copy the JARs in the
<MB_HOME>/client-lib
directory to theWEB-INF/lib
directory. Update the
index.html
file with the following content:<html> <head> <title>JMS Queue Sample Web Application</title> </head> <body bgcolor=white> <table border="0"> <tr> <td> <h1>Sample Queue Web Application</h1> </td> </tr> <tr> <td> <p>This is the home page for a sample web application which sends and receives queue messages using wso2 message broker.</p> </td> </tr> </table> <p>Please click on following link to run the sample : <ul> <li><a href="jmsqueue">Queue send receive sample servlet</a></li> </ul> </body> </html>
Your
<WEBAPP_HOME>
directory should now have the following content:-WebApp/ -WEB-INF/ -lib/ - andes-client-3.0.1.jar - log4j-1.2.13.jar - org.wso2.securevault-1.0.0-wso2v2.jar - geronimo-jms_1.1_spec-1.1.0.wso2v1.jar - org.wso2.carbon.logging-4.4.1.jar - slf4j-1.5.10.wso2v1.jar -classes/ -MyPackage/ - JmsQueue.java - SampleQueueReceiver.java - SampleQueueSender.java -web.xml Index.html
Open a terminal and navigate to the
<WEBAPP_HOME>
folder.Execute the following command from the terminal in order to create the .war file:
Jar -cvf jmsQueue.war *
jmsQueue.war
file in the WebApp
folder.Deploying the web application in Oracle Weblogic server
Deploy the web application in the Weblogic server. You can find detailed instructions in the Oracle documentation.
Testing the web application with WSO2 MB
Follow the steps given below to test how these JMS clients communicate with WSO2 MB.
- Be sure that the WSO2 MB server is started.
- Log in to the console of Weblogic server and invoke the
jmsQueue
web application. - Click Queue send receive sample servlet in the web application to execute the JMS queue send-receive sample operation.
- You can verify this from the console logs of the broker as well: A subscription has been added and deleted for the queue named "testQueue".