activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <tabish...@gmail.com>
Subject Re: Able to connect to broker but not recieving messages.
Date Tue, 08 Sep 2009 14:30:20 GMT
On Tue, 2009-09-08 at 06:27 -0700, gtsafas wrote:
> 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. 
> 

I've run your sample code and used a Java producer to send messages to
this Topic, everything works as expected, the client received all 2000
messages I sent while it was running.  I'm using the latest 5.3 SNAPSHOT
and the default broker configuration.

Regards
Tim.



-- 
Tim Bish
http://fusesource.com
http://timbish.blogspot.com/




Mime
View raw message