You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by nekresh <ne...@gmail.com> on 2010/08/11 00:24:03 UTC

C# client on qpid 0.6

Hello everyone.

I'm currently testing qpid 0.6 and have a few problems.

I've first tried the Messaging API.
On the C++ 0.6 broker, it simply doesn't work. Well, it's in the
documentation (http://qpid.apache.org/compatibility.html) so I won't
try more that way.
I then tried the Java 0.6 broker but wasn't able to receive message at
all. Even in debug trace, the message are received by the broker and
forwarded to the right queue but I never receive them.
Am I missing something ?
I'm creating the queue, binding it to the exchange amq.direct with the
correct routing_key.

static void Main(string[] args)
{
   Console.WriteLine("Init");

   var info = new QpidConnectionInfo();
   info.AddBrokerInfo(new AmqBrokerInfo("tcp", "localhost", 5672, false));
   info.Username = "guest";
   info.Password = "guest";

   using (var connection = new AMQConnection(info))
   {
       using (var ch = connection.CreateChannel(false,
Apache.Qpid.Messaging.AcknowledgeMode.PreAcknowledge))
       {
           ch.DeclareQueue("message_queue", true, false, false);
           ch.Bind("message_queue", "amq.direct", "test");

           var builder = ch.CreateConsumerBuilder("message_queue");
           using (var consumer = builder.Create())
           {
               Console.WriteLine("Ready");

               while (true)
               {
                   var message = consumer.Receive();
                   //var message = consumer.Receive(10000);
                   if (message != null)
                   {
                       Console.WriteLine("message received");
                   }
               }
           }
       }
   }
}

Then I tried the 0-10 API on the Java broker, but have strange behavior.
I can send and receive messages, but the messages are kept in the
queue. I receive the message only once but, when I restart my
consumer, then message are sent back to me.
As they aren't removed from the queue, I guess the queue will become
filled up very fast and stop working.

static void Main(string[] args)
{
   Console.WriteLine("Init");

   var client = new Client();
   client.Connect("localhost", 5672, "", "guest", "guest");
   var ch = client.CreateSession(10000);

   ch.QueueDeclare("message_queue", Option.DURABLE);
   ch.ExchangeBind("message_queue", "amq.direct", "test");

   ch.AttachMessageListener(new Listener(), "message_queue");
   ch.MessageSubscribe("message_queue");

   Console.WriteLine("Press enter to exit");
   Console.ReadLine();
   Console.WriteLine("Stopping");
   ch.Close();
   client.Close();
}

With a class Listener displaying the message received.
I haven't found a way to acknoledge received message in the 0-10 API,
only the listener way.
How is it possible to ack received message ?

In the list archive, I've found a message regarding which API
implementation to choose and the Messaging one was preferred. Do you
think it still applies now ?

Thanks for reading my (too) long message.

Nekresh

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: C# client on qpid 0.6

Posted by Gordon Sim <gs...@redhat.com>.
On 08/10/2010 11:24 PM, nekresh wrote:
> Hello everyone.
>
> I'm currently testing qpid 0.6 and have a few problems.
>
> I've first tried the Messaging API.

You mean the 0-8 based .Net client, right?

The term 'Messaging API' is now a little ambiguous. We have been working 
on a higher level and more uniform API with implementations available 
now in python, c++ and .Net (and with an addressing scheme for the JMS 
client that aims to give a more consistent view there also). This is not 
the same as the Qpid.Messaging implementation in .Net (that is an 0-8 
specific client).

> On the C++ 0.6 broker, it simply doesn't work. Well, it's in the
> documentation (http://qpid.apache.org/compatibility.html) so I won't
> try more that way.
> I then tried the Java 0.6 broker but wasn't able to receive message at
> all. Even in debug trace, the message are received by the broker and
> forwarded to the right queue but I never receive them.
> Am I missing something ?

Do you perhaps need a connection.start()? (Only speculation as I am not 
sufficiently familiar with this client)

> I'm creating the queue, binding it to the exchange amq.direct with the
> correct routing_key.
>
> static void Main(string[] args)
> {
>     Console.WriteLine("Init");
>
>     var info = new QpidConnectionInfo();
>     info.AddBrokerInfo(new AmqBrokerInfo("tcp", "localhost", 5672, false));
>     info.Username = "guest";
>     info.Password = "guest";
>
>     using (var connection = new AMQConnection(info))
>     {
>         using (var ch = connection.CreateChannel(false,
> Apache.Qpid.Messaging.AcknowledgeMode.PreAcknowledge))
>         {
>             ch.DeclareQueue("message_queue", true, false, false);
>             ch.Bind("message_queue", "amq.direct", "test");
>
>             var builder = ch.CreateConsumerBuilder("message_queue");
>             using (var consumer = builder.Create())
>             {
>                 Console.WriteLine("Ready");
>
>                 while (true)
>                 {
>                     var message = consumer.Receive();
>                     //var message = consumer.Receive(10000);
>                     if (message != null)
>                     {
>                         Console.WriteLine("message received");
>                     }
>                 }
>             }
>         }
>     }
> }
>
> Then I tried the 0-10 API on the Java broker, but have strange behavior.
> I can send and receive messages, but the messages are kept in the
> queue. I receive the message only once but, when I restart my
> consumer, then message are sent back to me.
> As they aren't removed from the queue, I guess the queue will become
> filled up very fast and stop working.
>
> static void Main(string[] args)
> {
>     Console.WriteLine("Init");
>
>     var client = new Client();
>     client.Connect("localhost", 5672, "", "guest", "guest");
>     var ch = client.CreateSession(10000);
>
>     ch.QueueDeclare("message_queue", Option.DURABLE);
>     ch.ExchangeBind("message_queue", "amq.direct", "test");
>
>     ch.AttachMessageListener(new Listener(), "message_queue");
>     ch.MessageSubscribe("message_queue");
>
>     Console.WriteLine("Press enter to exit");
>     Console.ReadLine();
>     Console.WriteLine("Stopping");
>     ch.Close();
>     client.Close();
> }
>
> With a class Listener displaying the message received.
> I haven't found a way to acknoledge received message in the 0-10 API,
> only the listener way.
> How is it possible to ack received message ?

I believe there is a MessageAccept() method on the session for that 
purpose (again I'm not sufficiently familiar with this client to give an 
authoritative answer, this is merely a suggestion from a glance at some 
of the examples).

> In the list archive, I've found a message regarding which API
> implementation to choose and the Messaging one was preferred. Do you
> think it still applies now ?

As mentioned above there is a new API that has been developed and that 
now includes support from .Net[1]. That was not part of the 0.6 release 
however, you would need to use trunk if you wanted to try it out. It 
will hopefully be included in the next release.

For 0.6 there are three options for .Net. The two you have tried above, 
which are protocol specific and frankly I think ripe for deprecation (we 
are short of active maintainers for these). In addition though there is 
an actively maintained WCF implementation (0-10 only at present)[2].

Hope this helps. The situation for .Net users is a little confusing at 
present but we want to improve on that. Thanks for your interest!

[1] 
http://qpid.apache.org/books/0.7/Programming-In-Apache-Qpid/html/ch02.html
[2] https://cwiki.apache.org/qpid/net-user-guide.html

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org