activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtsafas <gtsa...@rblt.com>
Subject Able to connect to broker but not recieving messages.
Date Tue, 08 Sep 2009 13:27:43 GMT

Hello, I had posted here last week and have yet to find a solution. I am
trying to recieve data from a topic and it is establishing the connection
but not returning data.

Here is my code;

using System;
using System.Collections.Generic;
using System.Text;
using Apache.NMS.ActiveMQ;
using Apache.NMS;
using Apache.NMS.Util;
using System.Threading;

namespace WindowsAuthenticator
{
    class Authenticator
    {
        protected static ITextMessage message = null;
        
        static void Main(string[] args)
        {
            //if (args.Length < 2)
            //{
            //    Console.WriteLine("Please specify the broker URL and
Port");
            //    Environment.Exit(0);
            //}

            //Authenticator authen = new Authenticator(args[0], args[1]);
            Authenticator authen = new Authenticator("192.168.42.30",
"61616");

           

        }

        Authenticator(string uri, string port)
        {
            //brokerURI = uri;
            //this.port = port;
            try
            {
                Uri connecturi = new Uri("tcp://" + uri + ":" + port +
"?wireFormat=openwire");
                Apache.NMS.ActiveMQ.ConnectionFactory factory = new
ConnectionFactory(connecturi);
                IConnection connection = factory.CreateConnection();
                ISession session = connection.CreateSession();

                IDestination destination =
SessionUtil.GetDestination(session, "topic://Topic.Realtime.Stats");
                Console.WriteLine("Using destination: " + destination);

                IMessageConsumer consumer =
session.CreateConsumer(destination);
                connection.Start();
                consumer.Listener += new MessageListener(OnMessage);

                Thread.Sleep(100000);
            }
            catch (Apache.NMS.NMSConnectionException e)
            {
                Console.WriteLine(e.Message);
            }


        }

        protected static void OnMessage(IMessage receivedMsg)
        {
            message = receivedMsg as ITextMessage;
            Console.WriteLine(message.Text);
        }
    }
}

Thank you to anyone that can help. 

-- 
View this message in context: http://www.nabble.com/Able-to-connect-to-broker-but-not-recieving-messages.-tp25346236p25346236.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message