tibco ems - Not able to retrieve messages from topic using EMS.NET API -


i trying write simple application send messages topic use input , show messages published on topic. there 2 command line executables - 1 publisher , subscriber. when publish messages on topic, can see messages getting submitted topic.

the following command shows there messages on topic (see f1.gif):-

show stat ems.test.topic 

enter image description here

the following command shows messages getting consumed subscribers (see f2.gif)

show stat consumers topic=ems.test.topic 

enter image description here

however, not able retrieve messages ems .net api. gets stuck on message msg = subscriber.receive();. made sure connection details , authentication details correct because used when publishing messages.

public string receivemessagesfromtopic(string topicname)         {             topicconnection connection = null;             string messagefrompublisher = string.empty;             try             {                 var factory = new tibco.ems.topicconnectionfactory(serverurl);                 connection = factory.createtopicconnection(username, password);                 topicsession session = connection.createtopicsession(false, session.auto_acknowledge);                 topic topic = session.createtopic(topicname);                 topicsubscriber subscriber = session.createsubscriber(topic);                 connection.start();                 while (true)                 {                    message msg = subscriber.receive();                     if (msg == null)                     {                         break;                     }                     if (msg textmessage)                     {                         textmessage tm = (textmessage) msg;                         messagefrompublisher = tm.text;                     }                  }                 connection.close();             }             catch (emsexception e)             {                 if (connection!=null)                 {                     connection.close();                 }                   throw;             }              return messagefrompublisher;         } 

there silly mistake in .net code. following while loop never returns there no return. need break while loop when message. duh!!!!

 while (true)  {          message msg = subscriber.receive();           if (msg == null)          {              break;          }          if (msg textmessage)          {              textmessage tm = (textmessage) msg;              messagefrompublisher = tm.text;              break;          }   } 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -