Wednesday, May 21, 2008

Java Messaging with Weblogic - Part 2

Now that we know the silly basics of Java Messaging, let us get our hands dirty by writing a little example.

Step 1 - If you dont already have Weblogic installed, you need to download and install the Weblogic Server from the BEA website (Try http://commerce.bea.com/showallversions.jsp?family=WLS ). I recommend the latest 10.x version. The setup file is huge, so be aware of the network traffic congestion and download charges (if applicable to you)

BEA provides a cool IDE for devloping Enterprise Java applications. It is called Workshop Platform. It is Eclipse based and you would find it easy to work wth. So, once you install the application, (assuming you have a Windows OS) you will be able to locate the command to start the Weblogic Server in Start --> Programs --> BEA Products --> Weblogic Server

It will open up a command prompt window and show you the scripts for loading the server. Once the server is up, you will be able to see the status on the console (Server Status changed to RUNNING) You can verify it by browsing to http://localhost:7001/console/ (You may need to enter the credentials that you supplied while installing Weblogic)



Step 2 - Now get to understand some more basics of JMS
In Webogic server, you would need to create a new JMS server. Then you need to create a JMS Connection Factory and JMS Queues so that your application will be able to publish messages into the Queue.

Dont you mind the technical Jargon mentioned above, take it off your head, follow the procedures and you will slowly uderstand what each term means.

So, let us go back to the Admin Console. Go to Home --> Services (Under Domain Configurations) -> JMS Servers (Under Messaging)

Next click on "Lock and Edit" from the Change Center, so that it allows you to edit the configuration.

Click on "NEW" to Create a new JMS Server and Enter the Server name here and click Next to select a store type. (Create a File Store)

Then select the target Weblogic server instance where you need to deploy this JMS Server. You can use the default server instance. Click Finish.

You have created a JMS Server.

Now you need to Create JMS Modules
Select Home --> Services --> Messaging --> JMS Modules.
Enter the required name and create a new JMS System module and select a target server instance for this module

Now you need to add resources (queue, connection factory etc) to this JMS Module
Click on the newly created JMS Module. In the next screen, select "Connection Factory" from the list of resources specified and click of Next and Enter the details for the Connection Factory. Enter Name and JNDI Name (this is required for connecting through the application later)
Next select a target server instance and then Finish

In the same way add a new destination Queue / Topic to the created JMS system Module resource. Enter the Queue name and JNDI name (This also will be required later for the application to connect) In the next step, select the JMS Server that you created earlier.


So we have seen how to create a JMS Server and a JMS Module within the server. In the
module we created a JMS connection Factory and a resource or a JMS queue. The
newly created resources can be seen in the resource summary.

Now next we will see how to connect to this resource through a Java Application :-)

No comments: