You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Matthew Xie <an...@163.com> on 2007/04/16 05:54:51 UTC

C# sync recieve message exception

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.