C# Client's Listener doesn't receive messages if you don't explicitly call 
Subscribe
------------------------------------------------------------------------------------

                 Key: AMQ-865
                 URL: https://issues.apache.org/activemq/browse/AMQ-865
             Project: ActiveMQ
          Issue Type: Bug
          Components: NMS (C# client)
         Environment: Windows XP, VS 2005, ActiveMQ 4.0.1
            Reporter: Denis Abramov


 Easiest way to reproduce the bug would be to start the consumer using the 
following code and then AFTER the consumer starts, start some producer (either 
java or C#) and you will notice that the consumer will not get any messages 
(through trial and error I found that calling Receive() on the consumer at 
least once will make you lose a message but the listener will kick back in): 

using System; 
using ActiveMQ; 
using ActiveMQ.Commands; 
using NMS; 

namespace JMSClient 
{ 
    /// <summary> 
    /// Summary description for Class1. 
    /// </summary> 
    class Class1 
    { 
        /// <summary> 
        /// The main entry point for the application. 
        /// </summary> 
        [STAThread] 
        static void Main(string[] args) 
        { 
            IConnectionFactory factory = new ConnectionFactory(new 
Uri("tcp://localhost:61616?jms.useAsyncSend=true")); 
            using (IConnection connection = factory.CreateConnection()) 
            { 
                Console.WriteLine("Created a connection!"); 

                ISession session = connection.CreateSession(); 
                IDestination destination = session.GetQueue("EXCEL.TESTQUEUE"); 
                Console.WriteLine("Using destination: " + destination); 

                // lets create a consumer and producer 
                IMessageConsumer consumer = 
session.CreateConsumer(destination); 
                consumer.Listener += new MessageListener(consumer_Listener); 

                while (true); 
            } 
        } 

        static void consumer_Listener(IMessage message) 
        { 
            if (message == null) 
            { 
                Console.WriteLine("No message received!"); 
            } 
            else 
            { 
                Console.WriteLine("Received message with text: " + 
((ActiveMQTextMessage)message).Text); 
            } 
         } 
    } 
} 


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to