0

I have a .NETcore application/client which has several defined endpoints to get data from the broker. One end point is to get a list of all of the addresses but when I run it it gives back an empty response. We are using amq7. Would the C# code need to be refactored to leverage Artemis? How would I be able to get Broker/Queue metrics in Artemis with .NET? Below is an example of the code the code we are using from the ActiveMQ NMS website

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.");
        }
Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
B.Allen
  • 79
  • 1
  • 7

1 Answers1

0

The default broker.xml disables advisory support, e.g.:

<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>

The key parameter is supportAdvisory=false which you can read more about in the documentation. You can set supportAdvisory=true or omit it entirely at which point you should be able to use advisories from your client.

Regarding other ways to get broker/queue metrics, ActiveMQ Artemis supports a number of different ways to access this data (e.g. JMX, HTTP via Jolokia, management messages, web console, CLI tools). You can read more about this in the documentation. The broker also supports exporting metrics via plugins so you can integrate with solutions like Prometheus.

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
  • But does this mean dotnet no longer supports using the advisory queue? – B.Allen Jun 04 '22 at 02:16
  • No, your dotnet client can still use advisories using the method I outlined in my answer (i.e. using `supportAdvisory=true` on the `acceptor` in `broker.xml`). I only mentioned the other alternatives because you asked, "How would I be able to get Broker/Queue metrics in Artemis with .NET?" There are lots of ways to get management/metric data from the broker. Advisories are one way along with the others I listed. – Justin Bertram Jun 04 '22 at 03:18
  • Is this assuming I'm running AMQ locally? Because Im not running it natively it's on a server AMQ that is so I don't have access to the broker.xml. I'm only able to view and access it programitically – B.Allen Jun 04 '22 at 13:05
  • It really doesn't matter where the broker is running as long as the configuration allows the client to access the advisory destinations. If you can't access the advisory destinations with the current configuration and you can't change the configuration yourself then you'll either need to work with the administrators of that machine to get the configuration changed appropriately or you'll have to change your application to get the information using one of the other options I outlined. – Justin Bertram Jun 06 '22 at 03:00