我有一个. NETcore应用程序/客户端,它有几个定义的endpoint来从代理获取数据。一个终端是获取所有地址的列表,但当我运行它时,它会返回一个空响应。我们使用的是amq7。C#代码需要重构以利用Artemis吗?我如何才能在Artemis中获取经纪人/队列指标。NET?下面是我们从ActiveMQ NMS网站使用的代码示例
using System;
using Apache.NMS;
using Apache.NMS.Util;
using Apache.NMS.ActiveMQ;
using Apache.NMS.ActiveMQ.Commands;
namespace AdvisoryExample
{
class AdvisoryExample
{
private IConnection connection;
private ISession session;
public const String QUEUE\_ADVISORY\_DESTINATION = "ActiveMQ.Advisory.Queue";
public const String TOPIC\_ADVISORY\_DESTINATION = "ActiveMQ.Advisory.Topic";
public const String TEMPQUEUE\_ADVISORY\_DESTINATION = "ActiveMQ.Advisory.TempQueue";
public const String TEMPTOPIC\_ADVISORY\_DESTINATION = "ActiveMQ.Advisory.TempTopic";
public const String ALLDEST\_ADVISORY\_DESTINATION = QUEUE\_ADVISORY\_DESTINATION + "," +
TOPIC\_ADVISORY\_DESTINATION + "," +
TEMPQUEUE\_ADVISORY\_DESTINATION + "," +
TEMPTOPIC\_ADVISORY\_DESTINATION;
AdvisoryExample()
{
IConnectionFactory factory = new ConnectionFactory();
connection = factory.CreateConnection();
connection.Start();
session = connection.CreateSession();
}
void EnumerateQueues()
{
Console.WriteLine("Listing all Queues on Broker:");
IDestination dest = session.GetTopic(QUEUE\_ADVISORY\_DESTINATION);
using(IMessageConsumer consumer = session.CreateConsumer(dest))
{
IMessage advisory;
while((advisory = consumer.Receive(TimeSpan.FromMilliseconds(2000))) != null)
{
ActiveMQMessage amqMsg = advisory as ActiveMQMessage;
if(amqMsg.DataStructure != null)
{
DestinationInfo info = amqMsg.DataStructure as DestinationInfo;
if(info != null)
{
Console.WriteLine(" Queue: " + info.Destination.ToString() );
}
}
}
}
Console.WriteLine("Listing Complete.");
}
默认的broc. xml
禁用咨询支持,例如:
<acceptor name="artemis">tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true;supportAdvisory=false;suppressInternalManagementObjects=false</acceptor>
关键参数是support port咨询=false
,您可以在留档中阅读更多信息。您可以设置support port咨询=true
或完全省略它,此时您应该能够使用客户端的建议。
关于获取代理/队列指标的其他方法,ActiveMQ Artemis支持多种不同的方式访问这些数据(例如JMX、通过JolokiaHTTP、管理消息、Web控制台、CLI工具)。您可以在留档中阅读更多相关信息。代理还支持通过插件导出指标,以便您可以与Prometheus等解决方案集成。