You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by gtsafas <gt...@rblt.com> on 2009/09/08 15:27:43 UTC
Able to connect to broker but not recieving messages.
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.
Re: Able to connect to broker but not recieving messages.
Posted by gtsafas <gt...@rblt.com>.
Thank you for your help, the error was overlooked on my end. I had the wrong
message type :-D
Timothy Bish wrote:
>
> 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/
>
>
>
>
>
--
View this message in context: http://www.nabble.com/Able-to-connect-to-broker-but-not-recieving-messages.-tp25346236p25349083.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Able to connect to broker but not recieving messages.
Posted by Timothy Bish <ta...@gmail.com>.
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/