[rabbitmq-discuss] Questions about running .NET binaries SendString.exe, SingleGet.exe, rabbitmqclt.bat

Tim Watson tim at rabbitmq.com
Tue Sep 10 09:53:47 BST 2013


Hi,

On 9 Sep 2013, at 19:29, Li, Mike wrote:
> I was able to complete http://www.rabbitmq.com/tutorials/tutorial-one-python.html to tutorial-three-phython.html
>  
> When I tried using SendString and SingleGet .NET binaries, and rabbitmqctl.bat I net getting much luck.

Have you tried writing code similar to the python tutorial using the .NET client? Looking at https://github.com/rabbitmq/rabbitmq-tutorials/tree/master/dotnet might help, though that's probably very out of date.

> But no message in the hello queue found.

Well indeed - queues are not magically created for you, you've got to declare them either in your code or using one of the various management tools.

>  
> Manually added message via Queue > hello > Publish message (and added messages using steps in tutorial-one-python.html)
>  

That's one way to do it.

> Tried getting the message failed also:
> c:\RabbitMQ.NetClient\bin>singleget "amqp://guest:guest@127.0.0.1:5672/" hello
>  

The reason for the the failure is tucked away in the exception message here:

> text="PRECONDITION_FAILED - parameters for queue 'hello' in vhost '/' not equivalent"

Before singleget attempts to issue a basic.get, it declares the target queue - using queue.declare - to ensure it's present. This is fine, since queue.declare is idempotent - if the queue already exists, the declaration acts like an assertion, otherwise it creates the queue. As you can see below, the code in SingleGet that declares the queue makes very specific assumptions about parameters:

            using (IModel ch = conn.CreateModel()) {
                conn.AutoClose = true;

                ch.QueueDeclare(queueName, false, false, false, null);
                BasicGetResult result = ch.BasicGet(queueName, false);
                if (result == null) {
                    Console.WriteLine("No message available.");
                } else {
                    ch.BasicAck(result.DeliveryTag, false);
                    Console.WriteLine("Message:");
                    DebugUtil.DumpProperties(result, Console.Out, 0);
                }

                return 0;
            }

So at the time that queue.declare method is issued to the server, if the queue that you manually created on the server was configured with *different* parameters, the queue.declare method will fail and a channel error will be raised, invalidating the channel and throwing an exception in the client.

>  
> Please advise.

Make sure that the queue you're consuming via SingleGet was declared with exactly these same parameters. Alternatively, write you own code to consume messages from the queue, and ensure that when calling the channel's QueueDeclare method, you provide the same parameters that the queue was originally declared/created with.

Cheers,
Tim

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130910/16949737/attachment.htm>


More information about the rabbitmq-discuss mailing list