activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Xie <ant_mira...@163.com>
Subject C# sync recieve message exception
Date Mon, 16 Apr 2007 03:54:51 GMT

Dear sirs,
  I meet a exception while recieving message by using recieve() method.
  if the amq server have no message, recieve method will throw out a
exception.

exception is bellow:
Using destination: queue://FOO.BAR
Caught: System.ArgumentOutOfRangeException: Number must be either
non-negative and less than or equal to Int32.MaxValue or -1.
Parameter name: millisecondsTimeout at
System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean
exitContext)
   at ActiveMQ.Dispatcher.Dequeue(TimeSpan timeout)
   at ActiveMQ.Dispatcher.Dequeue()
   at ActiveMQ.MessageConsumer.Receive()
   at ActiveMQ.TestMain.Main(String[] args) in C:\Documents and
Settings\xml\My
Documents\Visual Studio
2005\Projects\WindowsApplication1\WindowsApplication1\Te
stMain.cs:line 57
Stack:    at System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout,
Bool
ean exitContext)
   at ActiveMQ.Dispatcher.Dequeue(TimeSpan timeout)
   at ActiveMQ.Dispatcher.Dequeue()
   at ActiveMQ.MessageConsumer.Receive()
   at ActiveMQ.TestMain.Main(String[] args) in C:\Documents and
Settings\xml\My
Documents\Visual Studio
2005\Projects\WindowsApplication1\WindowsApplication1\Te
stMain.cs:line 57

following is my test code:
                IConnectionFactory factory = new ConnectionFactory(new
Uri("tcp://localhost:61616"));
                using (IConnection connection = factory.CreateConnection())
                {
                    Console.WriteLine("Created a connection!");
                    
                    ISession session = connection.CreateSession();
                    
                    IDestination destination = session.GetQueue("FOO.BAR");
                    Console.WriteLine("Using destination: " + destination);
                    
                    // lets create a consumer and producer
                    IMessageConsumer consumer =
session.CreateConsumer(destination);
                   
                    // lets consume a message
                    ActiveMQTextMessage message = (ActiveMQTextMessage)
consumer.Receive();
                    if (message == null)
                    {
                        Console.WriteLine("No message received!");
                    }
                    else
                    {
                        Console.WriteLine("Received message with ID:   " +
message.NMSMessageId);
                        Console.WriteLine("Received message with text: " +
message.Text);
                    }
                }

here i use amq 4.1.1. and i get the lastest dotnet amq code by 2007-4-16. 
my working enviroment is windows xp and MS vs2005 studio.

expecting your reply, thanks!

matt.
-- 
View this message in context: http://www.nabble.com/C--sync-recieve-message-exception-tf3582198s2354.html#a10009804
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message