JMS with .NET - WebLogic Server 10gR3 Example
By james.bayer on Sep 10, 2008
Update: 9/25/2009 - Since the documentation has moved to OTN, please refer to This link for the 11gR1 release of JMS .NET client documentation.
WebLogic Server 10gR3 contains an officially developed and supported .NET JMS client library for the first time. Previous versions of WebLogic Server have shipped with C library support which is still included. Some independent projects were able to use the C libraries to add unofficial .NET support in the past, but this latest WLS release takes things to the next level. There was a question today in the WLS forums about VB support, so I decided to try the example. In about 20 minutes I had the C# example working (I had WLS and Visual C# 2008 Express installed previously). Here are some screenshots and notes from my test.
Visual C# 2008 Express Edition or your favorite .NET compiler - this one is free and useful for doing the basics
I started by reviewing the new .NET client documentation for WebLogic Server. The basic gist of it is the default installation of WLS includes the WebLogic.Messaging.dll library in <WEBLOGIC_INSTALLATION>\modules\com.bea.weblogic.jms.dotnetclient_220.127.116.11. All you need to do is create a reference to that DLL and your ready to use the .NET WLS JMS API. In fact, a complete C# example console application is provided in the docs.
Build the C# Client
So the first thing is to do launch Visual C# and create a new project and select the Console Application template.
On the right hand side of the window, you should see the Solution Explorer, simply right click on the References and select Add Reference. You'll need to browse to the WebLogic.Messaging.dll location and click OK.
Then simply replace the existing CS file with the MessagingSample.cs file provided in the documentation. I found it simple enough to right click on the project and select Add->Class, name the file MessagingSample.cs and paste over the generated contents. Then I deleted the original .cs file that was created by default for the project.
Then just save and build the solution. F6 is the shortcut for this or you can use the menu Build->Build Solution. My .exe was placed in a location like this, but you can configure it: D:\MyData\Visual Studio 2008\Projects\WebLogicJMSExample\WebLogicJMSExample\bin\Release
WebLogic Server JMS Configuration
When you look at the source code in the example, you can see that it assumes some basic host and port information along with a basic queue and topic are available in WebLogic Server JMS.
If you use the examples server domain, which you can start from <WEBLOGIC_INSTALLATION>\wlserver_10.3\samples\domains\wl_server\bin\startWebLogic.cmd (sh) then you simply need to add a queue or topic or change the example C# code to point to the JNDI name of your queue and topic. Here's a screenshot of my examples server JMS module after I've done the configuration. Notice that I've set both the JNDI name and targeted the queue and topic to the subdeployment. Click the image to enlarge it.
I had a little trouble with the JNDI tree the first time through because I forgot to target the topic and queue to the subdeployment and therefore the JNDI name wasn't published correctly. To make sure you got it right, you can check the JNDI tree. From the console choose Environment->Servers->examplesServer(admin). The next page should have a link that says "View JNDI Tree". From there you can validate that the queue and topic are available as you expect. Since I had made a mistake the first time through, I found that I had to restart WLS to get the JNDI tree correct, but this step should not be necessary if you configure the JMS module correctly the first time.
Once the JNDI names are verified, try the executable.
After you run the test, you can look at the queue and the topic in the console and go to the monitoring tab. If the test ran successfully, you should see the message counts and client counts indicate that the test run.
You can download my Visual C# 2008 Solution.
If you plan to use this feature, please contact me at james dot bayer at oracle dot com or leave a comment. I know the JMS team is very interested to hear how our customers are planning to use the .NET support.