[rabbitmq-discuss] How to publish message

Tuan Nguyen tuannn225 at gmail.com
Thu Feb 13 10:08:10 GMT 2014


Hi everybody, I have just study RabbitMQ with SimpleAmqpClient, but when I 
published message using follow code:


#include <SimpleAmqpClient/SimpleAmqpClient.h>
>
> #include <iostream>
> #include <stdlib.h>
>
> using namespace AmqpClient;
> int main()
> {
>   
>     
>     char *szBroker = getenv("AMQP_BROKER");
>     
>     
>     Channel::ptr_t channel;
>     if (szBroker != NULL)
>         channel = Channel::Create(szBroker);
>     else        
>         channel = Channel::Create("127.0.0.1", 5672, "guest", "guest", 
> "/", 4096);
>
>     channel->DeclareQueue("alanqueue");
>     channel->BindQueue("alanqueue", "amq.direct", "alankey");
>     
>
>     BasicMessage::ptr_t msg_in = BasicMessage::Create();
>
>     msg_in->Body("Body massegae.");
>
>     channel->BasicPublish("amq.direct", "alankey", msg_in);
>
>     channel->BasicConsume("alanqueue", "consumertag");
>
>     BasicMessage::ptr_t msg_out = 
> channel->BasicConsumeMessage("consumertag")->Message();
>
>     std::cout << "Message text: " << msg_out->Body() << std::endl;
>     return 0;
> }
>

I don't see message in alanqueue queue. What wrong in here?

Sorry about my English

<https://lh5.googleusercontent.com/-9m3WYrZA3Lw/UvyZHib-6gI/AAAAAAAAAAY/3M3zAW9DtKo/s1600/Screenshot+from+2014-02-13+17%3A00%3A10.png>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140213/aeffe2fd/attachment.html>


More information about the rabbitmq-discuss mailing list