You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "gabriel.mancini" <ga...@gmail.com> on 2010/12/14 16:33:17 UTC

[NMS] Listing Queues mabe its time to NMX

 Hi Guys, 

   I m new in this list, and before all i must explain something.
   I Living in Brazil and my english it s like speaking with the tarzan =D,
please be pacient with me.

   I Decide using ActiveMQ/NMS in a project and the i need to say that "COOL
IMPLEMENTATION CONGRATS TO ALL", but i missed some important thing, get the
list off active queues, because i created the lists dinamic.
   Any way, i search for this feature a lot and nothing. i find (i dont
remember where, some guy speak something about NMX), i think it is a kind a
part of lib to have admin features, pls correct me if i wrong.
   And I know the open source evolves with needs, and how i have this need i
think maybe i can implement this feature. but how this is my first time i
feel kind lost, how i start this.

any on can help me? or join me to try do this?

thanks a lot 
best for all  
-- 
View this message in context: http://activemq.2283324.n4.nabble.com/NMS-Listing-Queues-mabe-its-time-to-NMX-tp3087307p3087307.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: [NMS] Listing Queues mabe its time to NMX

Posted by "gabriel.mancini" <ga...@gmail.com>.
Hi Tim, 

   I Don't have words for you man! thank you so much.
   you save the day!
   i think this code must to be in a official documentation, perfect
example!

Gabriel
-- 
View this message in context: http://activemq.2283324.n4.nabble.com/NMS-Listing-Queues-mabe-its-time-to-NMX-tp3087307p3088010.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: [NMS] Listing Queues mabe its time to NMX

Posted by Timothy Bish <ta...@gmail.com>.
On Tue, 2010-12-14 at 11:11 -0800, gabriel.mancini wrote:
> Hi Tim,
> 
>   So,I Just need get the list names of queues in C#
> 
> 


Here us a quick and dirty sample I just created to show you how its
basically done.

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.");
        }

        void EnumerateTopics()
        {
            Console.WriteLine("Listing all Topics on Broker:");

            IDestination dest =
session.GetTopic(TOPIC_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("   Topic: " +
info.Destination.ToString() );
                        }
                    }
                }
            }
            Console.WriteLine("Listing Complete.");
        }

        void EnumerateDestinations()
        {
            Console.WriteLine("Listing all Destinations on Broker:");

            IDestination dest =
session.GetTopic(ALLDEST_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)
                        {
                            string destType = info.Destination.IsTopic ?
"Topic" : "Qeue";
                            destType = info.Destination.IsTemporary ?
"Temporary" + destType : destType;
                            Console.WriteLine("   " + destType + ": " +
info.Destination.ToString() );
                        }
                    }
                }
            }
            Console.WriteLine("Listing Complete.");
        }

        void ShutDown()
        {
            session.Close();
            connection.Close();
        }

        public static void Main (string[] args)
        {
            AdvisoryExample ex = new AdvisoryExample();

            ex.EnumerateQueues();
            ex.EnumerateTopics();
            ex.EnumerateDestinations();
            ex.ShutDown();
        }
    }
}


Regards

-- 
Tim Bish
------------
FuseSource
Email: tim.bish@fusesource.com
Web: http://fusesource.com
Twitter: tabish121
Blog: http://timbish.blogspot.com/



Re: [NMS] Listing Queues mabe its time to NMX

Posted by "gabriel.mancini" <ga...@gmail.com>.
Hi Tim,

  So,I Just need get the list names of queues in C#


-- 
View this message in context: http://activemq.2283324.n4.nabble.com/NMS-Listing-Queues-mabe-its-time-to-NMX-tp3087307p3087763.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: [NMS] Listing Queues mabe its time to NMX

Posted by Timothy Bish <ta...@gmail.com>.
On Tue, 2010-12-14 at 09:27 -0800, gabriel.mancini wrote:
> Hi Tim,
> 
>   Thank you for your answer, ok i will do that.
>   I think its good start get the NMS project and create one using skeleton
> structure, what you think?
> 
> Gabriel 

Not sure what you're asking here?  What is it you are really looking to
do with NMS and what information do you need access to on the Broker?


-- 
Tim Bish
------------
FuseSource
Email: tim.bish@fusesource.com
Web: http://fusesource.com
Twitter: tabish121
Blog: http://timbish.blogspot.com/



Re: [NMS] Listing Queues mabe its time to NMX

Posted by "gabriel.mancini" <ga...@gmail.com>.
Hi Tim,

  Thank you for your answer, ok i will do that.
  I think its good start get the NMS project and create one using skeleton
structure, what you think?

Gabriel 
-- 
View this message in context: http://activemq.2283324.n4.nabble.com/NMS-Listing-Queues-mabe-its-time-to-NMX-tp3087307p3087568.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.

Re: [NMS] Listing Queues mabe its time to NMX

Posted by Timothy Bish <ta...@gmail.com>.
On Tue, 2010-12-14 at 07:33 -0800, gabriel.mancini wrote:
> Hi Guys, 
> 
>    I m new in this list, and before all i must explain something.
>    I Living in Brazil and my english it s like speaking with the tarzan =D,
> please be pacient with me.
> 
>    I Decide using ActiveMQ/NMS in a project and the i need to say that "COOL
> IMPLEMENTATION CONGRATS TO ALL", but i missed some important thing, get the
> list off active queues, because i created the lists dinamic.
>    Any way, i search for this feature a lot and nothing. i find (i dont
> remember where, some guy speak something about NMX), i think it is a kind a
> part of lib to have admin features, pls correct me if i wrong.
>    And I know the open source evolves with needs, and how i have this need i
> think maybe i can implement this feature. but how this is my first time i
> feel kind lost, how i start this.
> 
> any on can help me? or join me to try do this?
> 
> thanks a lot 
> best for all  

There currently is no such thing as NMX, so the first thing you'd have
to do is create that project and code it up :)  

If you just need to get some statistics from the broker you could use
advisory messages see:  http://activemq.apache.org/advisory-message.html

Regards

-- 
Tim Bish
------------
FuseSource
Email: tim.bish@fusesource.com
Web: http://fusesource.com
Twitter: tabish121
Blog: http://timbish.blogspot.com/