IBM.XMS Error CWSMQ0180E - Creating of Subscriber via Queue

Damir Dobric Posts

Next talks:

 

Damir@Phone    

Follow me on Twitter: #ddobric



 

 

Archives

When trying to initialize Ibm.Xms durable subscriber you may get following error:

CWSMQ0180E: The name is not valid for this Destination : durablesubscription.test. An application supplied an invalid name for the Destination. Check the supplied name conforms to Naming and URI specification.

The error description is a bit wired, because the reason why the error is thrown can be wrong initialization. It is important to know,
that durable subscriber should be used with topic based communication only. If the queue based communication is initialized
the common consumer (session.CreateConsumer()) should be used instead of durable subscriber (session.CreateDurableSubscriber()).

The example below shows using of durable subscriber based on queue communication. This will throw the error described below.

image

Unformatted code below:

static void createQueue()
     {
         IConnectionFactory cf = getFactory();

         using (IConnection connection = cf.CreateConnection(null, null))
         {
             connection.ClientID = "SomeUniqueText";

             using (ISession session = connection.CreateSession(false, AcknowledgeMode.AutoAcknowledge))
             {
                 using (IDestination destination = session.CreateQueue("queue://durablesubscription.test"))
                 {
                     destination.SetIntProperty(XMSC.DELIVERY_MODE, 1); //"non-persistent"

                     //using (IMessageConsumer consumer = session.CreateConsumer(destination))
                     using (IMessageConsumer consumer = session.CreateDurableSubscriber(destination, "DurableSubscription3"))
                     {
                         // IMessageConsumer consumer2 = session.CreateDurableSubscriber(destination, "DurableSubscription1");

                         IMessageProducer producer = session.CreateProducer(destination);

                         connection.Start();

                         int cnt = 3;

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


Posted Sep 15 2008, 10:01 PM by Damir Dobric
Filed under:
developers.de is a .Net Community Blog powered by daenet GmbH.