用于IBM MQ的.Net AMQP客户端

我试图使用我的.Net应用程序中的AMQP 1.0通道连接到IBM MQ 9.0。

MQ Light门户目前仅支持Nodejs,ruby,java和python客户端。 我们有.Net的MQ Light AMQP客户端吗?

我曾尝试使用Amqpnetlite客户端连接到IBM MQ 9

namespace AMQPNetLiteSample { class Program { static void Main(string[] args) { Console.WriteLine("Start"); //Address addr = new Address("10.58.139.97", 1234, "Username","password", "/", "AMQP"); Address addr = new Address("amqp://10.58.139.97:1234"); Connection con = new Connection(addr); con.Closed += con_Closed; Console.WriteLine("Created connection"); Session session = new Amqp.Session(con); session.Closed += session_Closed; Console.WriteLine("Created session"); SenderLink link = new SenderLink(session, "sender_12565455877", "/public"); Console.WriteLine("Created link"); var message = new Message(); message.Properties = new Properties(); message.Properties.Subject = "mysamplemsg"; message.ApplicationProperties = new ApplicationProperties(); message.ApplicationProperties["myprop"] = "Hello World"; Console.WriteLine("sending message"); link.Send(message); } static void session_Closed(AmqpObject sender, Error error) { Console.WriteLine("Session closed"); Console.WriteLine(error.ToString()); } static void con_Closed(AmqpObject sender, Error error) { Console.WriteLine("Connection closed"); Console.WriteLine(error.ToString()); } } } 

但是我无法成功build立联系。 启动SenderLink时,得到2035个MQRC_NOT_AUTHORIZEDexception。 但是,如果不尝试更改IBM MQ 9.0 Server中的任何通道身份validation(如果使用MQ Light nodejs示例(send.js)),则可以连接并向AMQP通道发送消息。

请build议上述代码是否需要更改。

是否有人成功地与任何其他.Net 1.0 AMQP客户端build立了与IBM MQ的通信? 在这里需要你的帮助。 谢谢。

似乎即使未configuration用户名和密码,MQ代理也需要SASL协商来进行连接。 您可以在amqpnetlite上启用SASL匿名,如下所示。

 Address address = new Address("amqp://10.58.139.97:1234"); Connection connection = new Connection(address, SaslProfile.Anonymous, null, null); Session session = new Session(connection); SenderLink sender = new SenderLink(session, "sender-12345", "/public"); Message message = new Message("Hello"); message.Properties = new Properties() { MessageId = "msg", To = "q1" }; sender.Send(message); connection.Close(); 

也可以对ConnectionFactory执行相同的操作。

 Address address = new Address("amqp://10.58.139.97:1234"); var factory = new ConnectionFactory(); factory.SASL.Profile = SaslProfile.Anonymous; Connection connection = await factory.CreateAsync(address);