You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by oliver2010 <zz...@sina.com> on 2010/08/18 03:17:32 UTC

About Using Advisory Messages In .net

I am using Activemq in .net (c#)
I wan't to monitor consumers and producers's count and their ip addresss
where they connected. 
I download apache.nms and apache.nms.activemq.
And  Wants to realize the monitoring through Advisory Messages.
But I can't find the corresponding function in Apache.nms.dll and
apache.nms.activemq.dll, what should I do? 
-- 
View this message in context: http://old.nabble.com/About-Using-Advisory-Messages-In-.net-tp29449308p29449308.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: About Using Advisory Messages In .net

Posted by oliver2010 <zz...@sina.com>.
I create a MessageConsumer that listens on the advisory topic.

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Apache.NMS;
using Apache.NMS.ActiveMQ;
using Apache.NMS.ActiveMQ.Commands;
using System.IO;
using System.Xml.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

namespace Monitor
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                //Create the Connection factory   
                IConnectionFactory factory = new
ConnectionFactory("tcp://192.168.7.51:61616/");


                //Create the connection   
                using (IConnection connection = factory.CreateConnection())
                {
                    connection.ClientId = "monitor";
                    connection.Start();

                    //Create the Session   
                    using (ISession session = connection.CreateSession())
                    {
                        IDestination destination =
session.GetDestination("ActiveMQ.Advisory.Connection",DestinationType.Topic);
                        //Create the Consumer   
                        IMessageConsumer consumer =
session.CreateConsumer(destination);

                        consumer.Listener += new
MessageListener(consumer_Listener);

                        Console.ReadLine();
                    }
                    connection.Stop();
                    connection.Close();
                }
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }

        static void consumer_Listener(IMessage message)
        {
            ActiveMQMessage msg = (ActiveMQMessage)message;
            Console.WriteLine(DateTime.Now.ToString() + " : " +
msg.ToString());
        }
    }
}

Result:

2010/8/19 11:00:06 : ActiveMQMessage[ commandId = 0, responseRe
roducerId = ID:DEV-01-3900-1282113492312-1:0:0:0, Destination =
.Advisory.Connection, TransactionId = , OriginalDestination = ,
EV-01-3900-1282113492312-1:0:0:0:23:34, OriginalTransactionId =
oupSequence = 0, CorrelationId = , Persistent = False, Expirati
= 0, ReplyTo = , Timestamp = 0, Type = Advisory, Content = , Ma
s = System.Byte[], DataStructure = ConnectionInfo[ commandId =
ed = True, ConnectionId = ID:X-PC-1489-634178124065831258-1:0,
r, Password = , UserName = , BrokerPath = , BrokerMasterConnect
eable = False, ClientMaster = False ], TargetConsumerId = ID:X-
065831258-1:0:1:1, Compressed = False, RedeliveryCounter = 0, B
ival = 0, UserID = , RecievedByDFBridge = False, Droppable = Fa
BrokerInTime = 1282186812265, BrokerOutTime = 1282186812265 ]

***********************************************************

The question is i can't get the consumer't ip address? How to get it?
-- 
View this message in context: http://old.nabble.com/About-Using-Advisory-Messages-In-.net-tp29449308p29477957.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: About Using Advisory Messages In .net

Posted by Timothy Bish <ta...@gmail.com>.
On Tue, 2010-08-17 at 18:17 -0700, oliver2010 wrote:
> I am using Activemq in .net (c#)
> I wan't to monitor consumers and producers's count and their ip addresss
> where they connected. 
> I download apache.nms and apache.nms.activemq.
> And  Wants to realize the monitoring through Advisory Messages.
> But I can't find the corresponding function in Apache.nms.dll and
> apache.nms.activemq.dll, what should I do? 

What methods are you looking for?

To receive advisory messages in NMS just create a MessageConsumer that
listens on the advisory topic you are interested in, they are named on
the ActiveMQ wiki page located here:

http://activemq.apache.org/advisory-message.html

Regards

-- 
Tim Bish

Open Source Integration: http://fusesource.com
ActiveMQ in Action: http://www.manning.com/snyder/

Follow me on Twitter: http://twitter.com/tabish121
My Blog: http://timbish.blogspot.com/