IBM MQ 的 .Net AMQP 客户端
.Net AMQP client for IBM MQ
我正在尝试使用我的 .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());
}
}
}
但是我无法成功建立连接。启动 SenderLink 时,我收到 2035 MQRC_NOT_AUTHORIZED 异常。
但是,在不更改 IBM MQ 9.0 服务器中的任何通道身份验证的情况下,如果我尝试使用 MQ Light nodejs 示例 (send.js),我能够连接并将消息发送到 AMQP 通道。
以上代码是否需要修改请提出。
是否有人成功地与任何其他 .Net 1.0 AMQP 客户端建立了与 IBM MQ 的通信?这里需要你的帮助。谢谢
似乎即使未配置用户名和密码,MQ 代理也需要 SASL 协商才能连接。您可以按如下方式在 amqpnetlite 上启用 SASL Anonymous。
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);
我正在尝试使用我的 .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());
}
}
}
但是我无法成功建立连接。启动 SenderLink 时,我收到 2035 MQRC_NOT_AUTHORIZED 异常。 但是,在不更改 IBM MQ 9.0 服务器中的任何通道身份验证的情况下,如果我尝试使用 MQ Light nodejs 示例 (send.js),我能够连接并将消息发送到 AMQP 通道。
以上代码是否需要修改请提出。
是否有人成功地与任何其他 .Net 1.0 AMQP 客户端建立了与 IBM MQ 的通信?这里需要你的帮助。谢谢
似乎即使未配置用户名和密码,MQ 代理也需要 SASL 协商才能连接。您可以按如下方式在 amqpnetlite 上启用 SASL Anonymous。
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);