【发布时间】:2016-12-14 03:42:48
【问题描述】:
我正在尝试使用 AMQP 1.0 通道从我的 .Net 应用程序连接到 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());
}
}
}
但我无法成功建立连接。启动 SenderLink 时,我收到 2035 MQRC_NOT_AUTHORIZED 异常。 但是,在不更改 IBM MQ 9.0 Server 中的任何通道身份验证的情况下,如果我使用 MQ Light nodejs 示例 (send.js) 进行尝试,我可以连接并向 AMQP 通道发送消息。
请建议上述代码是否需要任何更改。
是否有人成功地与任何其他 .Net 1.0 AMQP 客户端建立了与 IBM MQ 的通信?在这里需要你的帮助。谢谢。
【问题讨论】:
-
理论上任何 AMQP 客户端都应该工作。您可以在 MQ 队列管理器的错误日志中找到有关 NO_AUTHORIZED 原因的详细信息。 (AMKERR01.LOG)