[
https://issues.apache.org/activemq/browse/AMQNET-64?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_40167
]
dholroyd edited comment on AMQNET-64 at 9/23/07 8:33 AM:
--------------------------------------------------------------
So a cast from double to int appears to be the immediate problem. Here's a
naive workaround,
{noformat}
--- src/main/csharp/ActiveMQ/Dispatcher.cs (revision 578465)
+++ src/main/csharp/ActiveMQ/Dispatcher.cs (working copy)
@@ -127,8 +127,17 @@
while (!bClosed && rc == null)
{
- if(
!messageReceivedEventHandle.WaitOne((int)timeout.TotalMilliseconds, false) )
+ int wait;
+ if (timeout.TotalMilliseconds > Int32.MaxValue)
{
+ wait = Int32.MaxValue;
+ }
+ else
+ {
+ wait = (int)timeout.TotalMilliseconds;
+ }
+ if( !messageReceivedEventHandle.WaitOne(wait, false));
+ {
break;
}
lock (semaphore)
{noformat}
But when this codepath is hit, the test application doesn't receive any message
({{consumer.Receive()}} returns {{null}}).
(Feels as if the no-args version of Dequeue() would do better to pass a
{{null}} timeout to indicate 'wait forever', too.)
was (Author: dholroyd):
So a cast from double to int appears to be the immediate problem. Here's a
naive workaround,
{noformat}
--- src/main/csharp/ActiveMQ/Dispatcher.cs (revision 578465)
+++ src/main/csharp/ActiveMQ/Dispatcher.cs (working copy)
@@ -127,8 +127,17 @@
while (!bClosed && rc == null)
{
- if(
!messageReceivedEventHandle.WaitOne((int)timeout.TotalMilliseconds, false) )
+ int wait;
+ if (timeout.TotalMilliseconds > Int32.MaxValue)
{
+ wait = Int32.MaxValue;
+ }
+ else
+ {
+ wait = (int)timeout.TotalMilliseconds;
+ }
+ if( !messageReceivedEventHandle.WaitOne(wait, false));
+ {
break;
}
lock (semaphore)
{noformat}
But when this codepath is hit, the test application doesn't recieve an error
message.
(Feels as if the no-args version of Dequeue() would do better to pass a
{{null}} timeout to indicate 'wait forever', too.)
> occasional exception in ActiveMQ.Dispatcher.Dequeue() : millisecondsTimeout
> must be either non-negative and less than or equal to Int32.MaxValue or -1.
> -------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: AMQNET-64
> URL: https://issues.apache.org/activemq/browse/AMQNET-64
> Project: ActiveMQ .Net
> Issue Type: Bug
> Components: ActiveMQ Client
> Environment: .NET 2.0, Windows 2000 Server under VMware,
> https://svn.apache.org/repos/asf/activemq/activemq-dotnet/trunk @ 578465
> Reporter: David Holroyd
> Assignee: James Strachan
>
> I tried a lightly modified version of the example code from
> http://activemq.apache.org/nms/nms.html and find that every few invocations
> of the test program, I see the following exception, rather than the normal
> 'Received message' output:
> {noformat}
> Unhandled Exception: 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 Test.Bridge.Main(String[] args)
> {noformat}
> The code in question is,
> {code:title=Bridge.cs}
> namespace Test {
> using System;
> using NMS;
> using ActiveMQ;
> public class Bridge {
> public static void Main(string[] args) {
> IConnectionFactory factory = new ConnectionFactory(new
> Uri("tcp://192.168.9.162: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);
>
> IMessageProducer producer =
> session.CreateProducer(destination);
> producer.Persistent = true;
>
> // lets send a message
> ITextMessage request =
> session.CreateTextMessage("Hello World!");
> request.NMSCorrelationID = "abc";
> request.Properties["NMSXGroupID"] = "cheese";
> request.Properties["myHeader"] = "James";
>
> producer.Send(request);
>
> // lets consume a message
> ITextMessage message = (ITextMessage)
> 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);
> }
> }
> }
> }
> }
> {code}
> The C# code is talking to ActiveMQ 4.1.1 running on the Linux host (I'm using
> NMS within VMware).
> I'll try to nose around the code and work out what's happening, but this is
> the first time I've ever worked with C#.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.