Details
Description
I'm using ActiveMQ .Net to connect to ActiveMQ from Mono application on linux.
I've downloaded new (12-12-2008, rev. 726083) version of ActiveMQ .Net and started from testing new feature: FAILOVER transport.
First test made on Windows were very promising, but trying to run my application on linux caused an error.
I've invested it a bit and found out this:
On linux Mono the System.Uri constructor causes error while parsing composite uri, because it replaces all '//' with '/'. And tries to connect to 'tcp:/localhost:61616' for example.
I've tested it on newest Mono 2.0 SUSE with the same result.
Uris, I've tried:
failover:(tcp://192.168.44.244:61616)
failover:(tcp://192.168.44.244:61616)/
failover://localhost/(tcp://192.168.44.244:61616)
failover://localhost/(tcp://192.168.44.244:61616)/
All with the same result (
Illustration.
I modified Apache.NMS.ActiveMQ.ConnectionFactory constructors as below:
(...)
public ConnectionFactory(string brokerUri, string clientID)
: this(new Uri(brokerUri), clientID)
(...)
public ConnectionFactory(Uri brokerUri, string clientID)
(...)
and prepare simple islustrating program:
using System;
using Apache.NMS;
using Apache.NMS.ActiveMQ;
namespace IssueExample
{
internal class ConsoleTracer : ITrace
{
public bool IsDebugEnabled { get
public bool IsInfoEnabled { get { return true; }
}
public bool IsWarnEnabled { get
public bool IsErrorEnabled { get { return true; }
}
public bool IsFatalEnabled { get
}
public void Debug(string message)
public void Info(string message)
{ Console.WriteLine("INFO:" + message); }public void Warn(string message)
{ Console.WriteLine("WARN:" + message); }public void Error(string message)
{ Console.WriteLine("ERROR:" + message); }public void Fatal(object message)
{ Console.WriteLine("FATAL:" + message); }}
class Program
{
public static void Main(string[] args)
}
}
Running my program the output was:
- mono IssueExample.exe failover://localhost/(tcp://192.168.44.244:61616\,tcp://192.168.44.244:61616)/
DEBUG:ConnectionFactory(Uri brokerUri, string clientID): brokerUri='failover://localhost/(tcp:/192.168.44.244:61616,tcp:/192.168.44.244:61616)/'
DEBUG:ConnectionFactory(string brokerUri, string clientID): brokerUri='failover://localhost/(tcp://192.168.44.244:61616,tcp://192.168.44.244:61616)/'
DEBUG:Reconnect was triggered but transport is not started yet. Wait for start to connect the transport.
DEBUG:Started.
DEBUG:Creating reconnect task
DEBUG:Waking up reconnect task
INFO:Waiting for transport to reconnect.
DEBUG:Attempting connect to: tcp:/192.168.44.244:61616
DEBUG:Opening socket to: on port: -1
DEBUG:Connect fail to: tcp:/192.168.44.244:61616, reason: System.ArgumentOutOfRangeException: Argument is out of range.
Parameter name: Invalid port
at System.Net.IPEndPoint.set_Port (Int32 value) [0x00000]
at System.Net.IPEndPoint..ctor (System.Net.IPAddress address, Int32 port) [0x00000]
at Apache.NMS.ActiveMQ.Transport.Tcp.TcpTransportFactory.Connect (System.String host, Int32 port) [0x00000]
at Apache.NMS.ActiveMQ.Transport.Tcp.TcpTransportFactory.CompositeConnect (System.Uri location) [0x00000]
at Apache.NMS.ActiveMQ.Transport.TransportFactory.CompositeConnect (System.Uri location) [0x00000]
at Apache.NMS.ActiveMQ.Transport.Failover.FailoverTransport.doReconnect () [0x00000]
DEBUG:Waiting 10 ms before attempting connection.
(...)
<Infinit loop of reconnects>