developers.de
daenet's .NET Community

IBM.XMS error CWSMQ0115E - Creating durable subscriber

Damir Dobric Posts

 

Damir@Phone    



My upcoming sessions:

AppFabric Applications at
NRW Conf 2011
09.Sept.2011 Wuppertal

HTML5 widgets in WP7+
Monodroid
Mobility Day
21.Sept.2011 - Zagreb

AppFabric and WCF sessions at
Advanced Developer Conference
26.-27. Oktober 2011 in Frankenthal

AppFabric Applications, queues, topics and more at
Prio Conference
02. - 03. November 2011 in Meistersingerhalle Nürnberg

AppFabric Applications deep dive hosted by
.NET User Group Frankfurt
17.Nov.2011 18.30-22.30 Microsoft - Bad Homburg 

 

 

When creating durable subscriber by using of Ibm.Xms, you may get following exception:

"ClientId on the connection has not been set. Please set the Client ID on the Connection object or using the ConnectionFactory in order to use this functionality."

or this one:

CWSMQ0115E: Use of an un-initialised ClientId is not permitted. The ClientId on the connection has not been set. Please set the Client ID on the Connection object or using the ConnectionFactory in order to use this functionality.

In general this platform allows you to create two kinds of consumers: Durable and none durable one. According to IBM notation, the first one is known as Consumer and second one as Durable Subscriber.

To create the none durable consumer use following code:

IDestination destination = ...

session.CreateConsumer(destination);

Similar, durable subscriber can be created with following code:

IDestination destination = ...

connection.ClientID = "SomeUniqueText";

session.CreateConsumer(destination);


Here is the full code. If the red-marked line is missing, the exception above will be thrown:

image

 

Unformatted code below:

using System;
using System.Collections.Generic;
using System.Text;
using IBM.XMS;

namespace Ibm.XmlConsumer
{
    class Program
    {
        static void Main(string[] args)
        {
            XMSFactoryFactory factory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);

            IConnectionFactory cf = factory.CreateConnectionFactory();

            cf.SetStringProperty(XMSC.WMQ_HOST_NAME, "192.168.0.131");
            cf.SetIntProperty(XMSC.WMQ_PORT, 1414);
            cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, 1); // Means client
            cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, "QM1");
            cf.SetIntProperty(XMSC.WMQ_BROKER_VERSION, 0); // Means brocker
            cf.SetStringProperty(XMSC.JMS_IBM_MSGTYPE, "bytes"); // Binary message

            //using (IConnectionFactory connectionFactory = cf.CreateConnection("UserId", "Password"))
            using (IConnection connection = cf.CreateConnection(null, null))
            {
                connection.ClientID = "SomeUniqueText";
                using (ISession session = connection.CreateSession(false, AcknowledgeMode.AutoAcknowledge))
                {
                    using (IDestination destination = session.CreateTopic("topic://daenet.eu/servicebus"))
                    {
                        destination.SetIntProperty(XMSC.DELIVERY_MODE, 1); //"non-persistent"
                        //using (IMessageConsumer consumer = session.CreateConsumer(destination))
                        using (IMessageConsumer consumer = session.CreateDurableSubscriber(destination, "hello durable world"))
                        {
                            connection.Start();

                            int cnt = 3;

                            IMessage recvMsg = null;
                            while (--cnt > 0)
                            {
                                // Receive the message                                   
                                recvMsg = consumer.Receive(30000);
                            }
                        }
                    }
                }
            }
        }
    }
}


Posted Sep 12 2008, 11:36 PM by Damir Dobric
Filed under:

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
daenet GmbH