Error sending message to a non-existent topic

No exception is thrown when using IBM.XMS to post messages to a topic that does not exist. When you try to do the same with a queue, I am kindly notified that the queue manager or queue does not exist.

This is how I create the connection and send messages to the topic:

XMSFactoryFactory xmsFactoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
IConnectionFactory ibmConnectionFactory = xmsFactoryFactory.CreateConnectionFactory();
ibmConnectionFactory.SetStringProperty(XMSC.WMQ_HOST_NAME, "frimasrv");
ibmConnectionFactory.SetIntProperty(XMSC.WMQ_PORT, 1415);
ibmConnectionFactory.SetStringProperty(XMSC.WMQ_CHANNEL, "CH1");
ibmConnectionFactory.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
ibmConnectionFactory.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, "API");

IConnection connection = ibmConnectionFactory.CreateConnection();
connection.ClientID = "client id";
ISession session = connection.CreateSession(false, AcknowledgeMode.AutoAcknowledge);

IDestination destination = session.CreateTopic("this.does.not.exist");
IMessageProducer producer = session.CreateProducer(destination);
IMessageConsumer durableConsumer = session.CreateDurableSubscriber(destination, "subscriptionName");

IMessage myMessage = session.CreateTextMessage("text");
producer.Send(myMessage);

      

Complement the call to session.CreateTopic (...) with session.CreateQueue (...) and session.CreateProducer (...) will fail. This is the behavior I also expect when using themes.

My questions:

Why is there no problem submitting to a topic that doesn't exist? Is part of my configuration wrong? Is there any other way to check if a theme actually exists?

+3


source to share


2 answers


Why is there no problem submitting to a topic that doesn't exist?

Because as soon as you post to a topic or subscribe to a topic, it exists. The queue manager will automatically animate it for you.

According to JMS 2.1 spec:

Some products require themes to be statically defined using linked authorization control lists, etc .; others don't even have a theme administration concept.

IBM MQ is one product that does not require themes to be statically defined.

You may have misunderstood the use of IBM objects in MQ. They do not define the topics themselves, but rather provide a pointer to the location in the topic hierarchy where the ACL is applied. For example, consider the following topic hierarchy:

Produce
   Fruits
      Apple
      Banana
      Cranberry
   Vegetables
      Asparagus
      Beet
      Celery

      

If you define a theme Fruits

and include it in the subject line Produce/Fruits

, you can allow users to post or subscribe to a portion of the theme tree from Produce / Fruits on down. Those with authorization won't be able to access Produce/Vegetables

unless you grant them access through the theme object pointing there.



It is generally best to define theme objects at a specific level in the theme tree. As you can see above, defining a theme object in Produce

gives access to the entire theme tree, but you only need one theme object. Define objects at the second level and you need two to cover the tree (one at Fruits

and one at Vegetables

), but have more granularity in the security model. Define topics at the third level and you have an extreme granularity, but there are also many topic objects to administer.

IBM MQ defines a default theme object SYSTEM.BASE.TOPIC

that points to the root of the global theme space. Anyone with access to SYSTEM.BASE.TOPIC

can access any topic. By default, this only includes MQ administrators.

If you define a topic with a name Fruits

and point it to the topic line Produce/Fruits

, then you have two options when you want to open that topic. If you open the subject object , IBM MQ will replace the subject with the string the object points to. You can also open the subject line directly . Either result gives the same effective resolution that IBM MQ always resolves based on the last subject line.

If you specify both a subject object and a subject string, the subject string in the specific object is used as a prefix for the string you provide. The two are concatenated to create a complete subject line. For example, if you specify both a theme object Fruits

(which points to a string Produce/Fruits

in the above example) and a string Produce/Fruits

, MQ concatenates them and animates the theme under the title Produce/Fruits/Produce/Fruits

. Try not to do this. If you need this, make sure you understand the mechanics as described in Combining topic strings .

If you check the IBM MQ Pub / Sub API or the IBM implementation of the theme factory connection, you will see that they contain two fields, one for the theme object and one for the theme string.

When you specify the subject of an object in your factory connection, that object must exist. Provide a subject line and MQ will automatically change it for you if you are authorized for that line.

I am assuming the id you are using has admin rights or has been granted access to SYSTEM.BASE.TOPIC

, since you can publish it at all. Therefore, you won't get any errors for any subject line that you post.

See also the Topic lines section of the manual for a general description of how IBM MQ manages a topic.

+2


source


Did you run the "IBM Message Service Client for .NET" installer?

XMS: XmsFactoryFactory stops skipping IBM.XMS.Impl



Here's another helpful post on SO:

How to get the status of the Websphere MQ network connection and how to reset the connection:

0


source







All Articles