IBM MQ XMS - 在 C# 中订阅多个主题
IBM MQ XMS - Subscribe to multiple Topics in C#
有没有办法使用星号 (*) 语法订阅所有报告主题?
例如:"MyData\version1.0\Reports\(*)"
p.s : 我正在使用 xms。
class MyXmsApp
{
static void Main(string[] args)
{
MyXmsApp app = new MyXmsApp();
app.Setup();
Console.ReadLine();
}
public void Setup()
{
XMSFactoryFactory xff = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
IConnectionFactory cf = xff.CreateConnectionFactory();
cf.SetStringProperty(XMSC.WMQ_HOST_NAME, "localhost");
cf.SetIntProperty(XMSC.WMQ_PORT, 1414);
cf.SetStringProperty(XMSC.WMQ_CHANNEL, "CLIENT");
cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, "QM_LOCAL");
cf.SetIntProperty(XMSC.WMQ_BROKER_VERSION, XMSC.WMQ_BROKER_V1);
IConnection conn = cf.CreateConnection();
Console.WriteLine("connection created");
ISession sess = conn.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
IDestination dest = sess.CreateQueue("queue://q");
IMessageConsumer consumer = sess.CreateConsumer(dest);
MessageListener ml = new MessageListener(OnMessage);
consumer.MessageListener = ml;
conn.Start();
Console.WriteLine("Consumer started");
}
private void OnMessage(IMessage msg)
{
ITextMessage textMsg = (ITextMessage)msg;
Console.Write("Got a message: ");
Console.WriteLine(textMsg.Text);
}
}
您在 MQ pub/sub 中想要的通配符是'#'。在您订阅主题字符串的示例中:
MyData/version1.0/报告/#
将订阅:
MyData/version1.0/Reports/DailyReport
MyData/version1.0/Reports/WeeklyReport
MyData/version1.0/Reports/MonthlyReport
更多信息在这里:
https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.pla.doc/q005010_.htm
有没有办法使用星号 (*) 语法订阅所有报告主题?
例如:"MyData\version1.0\Reports\(*)"
p.s : 我正在使用 xms。
class MyXmsApp
{
static void Main(string[] args)
{
MyXmsApp app = new MyXmsApp();
app.Setup();
Console.ReadLine();
}
public void Setup()
{
XMSFactoryFactory xff = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
IConnectionFactory cf = xff.CreateConnectionFactory();
cf.SetStringProperty(XMSC.WMQ_HOST_NAME, "localhost");
cf.SetIntProperty(XMSC.WMQ_PORT, 1414);
cf.SetStringProperty(XMSC.WMQ_CHANNEL, "CLIENT");
cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, "QM_LOCAL");
cf.SetIntProperty(XMSC.WMQ_BROKER_VERSION, XMSC.WMQ_BROKER_V1);
IConnection conn = cf.CreateConnection();
Console.WriteLine("connection created");
ISession sess = conn.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
IDestination dest = sess.CreateQueue("queue://q");
IMessageConsumer consumer = sess.CreateConsumer(dest);
MessageListener ml = new MessageListener(OnMessage);
consumer.MessageListener = ml;
conn.Start();
Console.WriteLine("Consumer started");
}
private void OnMessage(IMessage msg)
{
ITextMessage textMsg = (ITextMessage)msg;
Console.Write("Got a message: ");
Console.WriteLine(textMsg.Text);
}
}
您在 MQ pub/sub 中想要的通配符是'#'。在您订阅主题字符串的示例中:
MyData/version1.0/报告/#
将订阅:
MyData/version1.0/Reports/DailyReport
MyData/version1.0/Reports/WeeklyReport
MyData/version1.0/Reports/MonthlyReport
更多信息在这里: https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.pla.doc/q005010_.htm