Question

I'm hoping someone here will be able to aid me with my struggles with integration with ActiveMQ from C#. Here's what I did so far:

using Apache.NMS;
using Apache.NMS.ActiveMQ;
namespace JMSTest {
  class Program {
    static void Main(string[] args) {
      IConnectionFactory factory = new ConnectionFactory("tcp://localhost:61616/");
      IConnection connection = factory.CreateConnection();
      ISession session = connection.CreateSession();
    }
  }
}

Pretty basic stuff: just create a connection factory, then use it to create the connection and at the end create a session. Now when I execute this code this is the exception that's being thrown:

System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
   at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
   at System.String.Substring(Int32 startIndex, Int32 length)
   at Apache.NMS.ActiveMQ.OpenWire.StringPackageSplitter.StringPackageSplitterEnumerator.System.Collections.IEnumerator.get_Current()
   at Apache.NMS.ActiveMQ.OpenWire.OpenWireBinaryWriter.Write(String text)
   at Apache.NMS.ActiveMQ.OpenWire.BaseDataStreamMarshaller.LooseMarshalString(String value, BinaryWriter dataOut)
   at Apache.NMS.ActiveMQ.OpenWire.V2.ConnectionIdMarshaller.LooseMarshal(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut)
   at Apache.NMS.ActiveMQ.OpenWire.OpenWireFormat.LooseMarshalNestedObject(DataStructure o, BinaryWriter dataOut)
   at Apache.NMS.ActiveMQ.OpenWire.BaseDataStreamMarshaller.LooseMarshalCachedObject(OpenWireFormat wireFormat, DataStructure o, BinaryWriter dataOut)
   at Apache.NMS.ActiveMQ.OpenWire.V2.ConnectionInfoMarshaller.LooseMarshal(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut)
   at Apache.NMS.ActiveMQ.OpenWire.OpenWireFormat.Marshal(Object o, BinaryWriter ds)
   at Apache.NMS.ActiveMQ.Transport.Tcp.TcpTransport.Oneway(Command command) : Transport connection error: Index and length must refer to a location within the string.
Parameter name: length

Does anyone has any idea what's going on? I'm using Apache ActiveMQ version 5.2.0 (fresh download from their web site).

Was it helpful?

Solution

I tried the exact same thing you have here and it seemed to work. Someone on the intraweb responded to your request on Nabble that there was a bug (where?) that was fixed. Maybe download the latest version of Apache.NMS/Apache.NMS.ActiveMQ and try again.

Apache.NMS comes with Spring.NET - that's probably the best and easiest way to get Apache.NMS.

OTHER TIPS

Well, the problem is solved. It took a while but with the help of the post that Andy White sent I was able to get it up and running just the way I wanted.

The problem was of course that those libraries currently available at http://svn.apache.org/viewvc/activemq/activemq-dotnet/ are simply broken and don't work at all.

Thank you Andy!

Just to respond to the comment "It seems an overkill to use a framework that's over 25MB in size just to send and receive messages from/to a message queue."

I certainly agree and it is really a packaging issue, we include compiled binaries for .NET 1.1 through 3.0 (debug and release builds with .pdbs) reference docs, sample apps, and so on. If you look at the size the .dlls you need to create an ActiveMQ NMS based Spring.NET app it is

Common.Logging 28KB, Spring.Aop 152KB, Spring.Core 744KB, Spring.Data 340KB, and Spring.Messaging.Nns 104KB for a total of ~1.4MB.

Mark

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top