[rabbitmq-discuss] How to publish message

tuan225 tuannn225 at gmail.com
Thu Feb 13 10:17:36 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)

<http://rabbitmq.1065348.n5.nabble.com/file/n33320/Screenshot%2Bfrom%2B2014-02-13%2B17%253A00%253A10.png> 



--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/How-to-publish-message-tp33320.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list