简体   繁体   English

没有Spring.NET的Apache ActiveMQ访问

[英]Apache ActiveMQ access without Spring.NET

I'm hoping someone here will be able to aid me with my struggles with integration with ActiveMQ from C#. 我希望这里有人能够帮助我与C#中的ActiveMQ集成。 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). 我正在使用Apache ActiveMQ版本5.2.0(从其网站上重新下载)。

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. Intraweb上的某个人响应了您在Nabble上的请求,该请求已修复一个错误(在哪里?)。 Maybe download the latest version of Apache.NMS/Apache.NMS.ActiveMQ and try again. 也许下载最新版本的Apache.NMS / Apache.NMS.ActiveMQ,然后重试。

Apache.NMS comes with Spring.NET - that's probably the best and easiest way to get Apache.NMS. Apache.NMS随Spring.NET一起提供 -这可能是获得Apache.NMS的最佳和最简便的方法。

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." 只是为了回应评论“使用大小超过25MB的框架仅用于收发消息队列中的消息或从消息队列中接收消息似乎是过大的选择。”

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. 我当然同意,这确实是一个包装问题,我们包括适用于.NET 1.1到3.0的编译二进制文件(使用.pdbs进行调试和发布),参考文档,示例应用程序等。 If you look at the size the .dlls you need to create an ActiveMQ NMS based Spring.NET app it is 如果查看.dll的大小,则需要创建一个基于ActiveMQ NMS的Spring.NET应用程序。

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

Mark 标记

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. 花了一段时间,但是在Andy White发送的帖子的帮助下,我得以按照我想要的方式启动并运行它。

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. 问题当然是当前在http://svn.apache.org/viewvc/activemq/activemq-dotnet/上提供的那些库只是被破坏了,根本无法使用。

Thank you Andy! 谢谢安迪!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM