activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmc <>
Subject consumer question for NMS .Net app
Date Sat, 04 Oct 2014 13:44:00 GMT
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:

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
                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 =
                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
                IConnection connection = factory.CreateConnection();
                session = connection.CreateSession();

       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 =
                    request.NMSCorrelationID = Guid.NewGuid().ToString();
                    request.Properties["NMSXGroupID"] = "xyz";
                    request.Properties["myHeader"] = "xyzpubsub";


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
this is the error line : ITextMessage message = consumer.Receive() as
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

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

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:
Sent from the ActiveMQ - User mailing list archive at

View raw message