An updated simple WebLogic JMS client in .Net (C#)

In previous posts, we presented a simple WebLogic JMS client in Java here, and an updated one here.  We also presented a simple C# JMS program here.

In this post, we present a more or less equivalent C#/.Net implementation of the updated simple JMS client.  Please refer to the referenced posts for details of how to set up the necessary queues, etc. on WebLogic, and how to build and use this code.

Update: You can grab this code from our Subversion repository:
svn checkout

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebLogic.Messaging;

namespace SimpleJMSClient

  class Program

    private static string DEFAULT_URL = "t3://localhost:7101";
    private static string cfName = "weblogic.jms.ConnectionFactory";
    private static string DEFAULT_QUEUE = "jms/MarksQueue";
    private static string DEFAULT_USER = "weblogic";
    private static string DEFAULT_PASSWORD = "weblogic1";

    static void Main(string[] args)
      sendMessage("hello from .net with 1 arg");
                  "hello from .net with 5 args");

    static void sendMessage(string messageText)

    static void sendMessage(string url, string user, string password, string queueName, string messageText)
      // create properties dictionary
      IDictionary<string, Object> paramMap = new Dictionary<string, Object>();

      // add necessary properties
      paramMap[Constants.Context.PROVIDER_URL] = url;
      paramMap[Constants.Context.SECURITY_PRINCIPAL] = user;
      paramMap[Constants.Context.SECURITY_CREDENTIALS] = password;

      // get the initial context
      IContext context = ContextFactory.CreateContext(paramMap);

      // lookup the connection factory
      IConnectionFactory cf = context.LookupConnectionFactory(cfName);

      // lookup the queue
      IQueue queue = (IQueue)context.LookupDestination(queueName);

      // create a connection
      IConnection connection = cf.CreateConnection();

      // start the connection

      // create a session
      ISession session = connection.CreateSession(

      // create a message producer
      IMessageProducer producer = session.CreateProducer(queue);
      producer.DeliveryMode = Constants.DeliveryMode.PERSISTENT;

      // create a text message
      ITextMessage textMessage = session.CreateTextMessage(messageText);

      // send the message

      // CLEAN UP



About Mark Nelson

Mark Nelson is a Developer Evangelist at Oracle, focusing on microservices and messaging. Before this role, Mark was an Architect in the Enterprise Cloud-Native Java Team, the Verrazzano Enterprise Container Platform project, worked on Wercker, WebLogic and was a senior member of the A-Team since 2010, and worked in Sales Consulting at Oracle since 2006 and various roles at IBM since 1994.
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

3 Responses to An updated simple WebLogic JMS client in .Net (C#)

  1. Pingback: Simple JMS client in Scala | RedStack

  2. Pingback: An updated simple WebLogic JMS client | RedStack

  3. Pingback: An updated simple WebLogic JMS client

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s