activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Xie <ant_mira...@163.com>
Subject problem with openwire dotnet
Date Fri, 28 Jul 2006 07:34:33 GMT

I am using asynchronous approach to consume message by amq dotnet api.
the problem is that if i send serval messages to the amq server then i start
asynchronous approach consumer code to listen the message, but unexpectly i
found that nothing recieve. but if i send a message again then all the
messages are recieved include the lastest message.

here's the my test code:
        public void recieve(String queueName)
        {
            using (IConnection connection = factory.CreateConnection())
            {
                AcknowledgementMode acknowledgementMode =
AcknowledgementMode.ClientAcknowledge;
                ISession session =
connection.CreateSession(acknowledgementMode);

                IDestination destination = session.GetQueue(queueName);

                // lets create a consumer and producer
                IMessageConsumer consumer =
session.CreateConsumer(destination);
                
                //recieve the old message
//                IMessage message =
consumer.Receive(TimeSpan.FromMilliseconds(200));

                received = false;
                consumer.Listener += new MessageListener(OnMessage);

                Console.WriteLine("Start to listen messengers(program will
be exited upon received messenger)");
                WaitForMessageToArrive();

            }
        }

        protected void OnMessage(IMessage message)
        {
            ActiveMQTextMessage textmessage = (ActiveMQTextMessage)message;
            Console.WriteLine("Received message with ID:   {0}",
textmessage.NMSMessageId);
            String text = HttpUtility.UrlDecode(textmessage.Text);
            Console.WriteLine("Received message with text: " + text);

            message.Acknowledge();

            lock (semaphore)
            {
                received = true;
                Monitor.PulseAll(semaphore);
            }

        }

is there anything incrroect?
could someone do me a favor?
thanks!

matt
-- 
View this message in context: http://www.nabble.com/problem-with-openwire-dotnet-tf2013952.html#a5534983
Sent from the ActiveMQ - User forum at Nabble.com.


Mime
View raw message