On 10/04/2014 09:44 AM, dmc wrote:
details:
--------
created c# .net 4 dll for excel using the excel RTD interface
nms and nms.activemq dlls v 1.6.0 and 1.6.1

I start my broker as:
ApacheMQ\apache-activemq-5.10.0-bin\apache-activemq-5.10.0\bin\win64

Ive taken the out of the box settings for everything.

I register interest in an RTD topic from excel as:

         private ISession session;
         private bool blnUpdateNotifyCalled = false;
         private string sServiceAddress = "activemq:tcp://mypcname:61616";


         public object ConnectData(int topicId, ref Array Strings, ref bool
GetNewValues)
         {
                 string messageSubject = Strings.GetValue(0) as string;

                 String messageDestination = "topic://" + messageSubject;
                 _subscriptions.Add(topicId, messageDestination);
                 _destinations.Add(messageDestination, 0);
                 _topicId = topicId;

                 IDestination destination =
SessionUtil.GetDestination(session, messageDestination);
                 IMessageConsumer consumer =
session.CreateConsumer(destination);
                 consumer.Listener += new MessageListener(OnMessage);
                 GetNewValues = true;

                 //get the current value on bus
                 ITextMessage message = consumer.Receive() as ITextMessage;
                 return message.Text;..................

           }
another one-time setup method creates the types at service startup:
                {
                 Uri connecturi = new Uri(sServiceAddress);
                 IConnectionFactory factory = new
NMSConnectionFactory(connecturi);
                 IConnection connection = factory.CreateConnection();
                 session = connection.CreateSession();
                 connection.Start();
                }

        this is how i send a topic to the bus:

                 IDestination destination =
SessionUtil.GetDestination(session, "topic://" + topic + "~" + sField);
                 using ( IMessageProducer producer =
session.CreateProducer(destination) )
                 {
ITextMessage request =
session.CreateTextMessage(messageToPost);
                     request.NMSCorrelationID = Guid.NewGuid().ToString();
                     request.Properties["NMSXGroupID"] = "xyz";
                     request.Properties["myHeader"] = "xyzpubsub";
                     producer.Send(request);


=============================================


This all works perfectly well EXCEPT for when a topic with a value is
already on the bus and the ConnectData gets called and does not return any
value.
this is the error line : ITextMessage message = consumer.Receive() as
ITextMessage;
error =
"Apache.NMS.NMSException: Cannot set Async listeners on Consumers with a
prefetch limit of zero\r\n   at
Apache.NMS.ActiveMQ.MessageConsumer.CheckMessageListener() in
c:\\dev\\NMS.ActiveMQ\\src\\main\\csharp\\MessageConsumer.cs:line 1569\r\n
at Apache.NMS.ActiveMQ.MessageConsumer.Receive() in
c:\\dev\\NMS.ActiveMQ\\src\\main\\csharp\\MessageConsumer.cs:line 336\r\n
at RTDServers.RTDDataServer.ConnectData(Int32 topicId, Array& Strings,
Boolean& GetNewValues) in C:\\PubSubAddin\\PubSubAddin\\Subscribe.cs:line
160"

But when i change the value of the topic and the listener fires - the result
is returned.

Question:
How can i get the ConnectData to have a consumer object have a listener and
also return the value on the bus if one currently exisits?





















--
View this message in context: 
http://activemq.2283324.n4.nabble.com/consumer-question-for-NMS-Net-app-tp4686144.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

A topic consumer would only receive a message sent to the topic after it subscribed, unless it was a durable topic subscription which had been previously subscribed.

--
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.b...@redhat.com | www.redhat.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/

Reply via email to