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.

Reply via email to