Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT and AMQP-CPP sample
Forum Updated to NodeBB v4.3 + New Features

QT and AMQP-CPP sample

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 4.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RahibeMeryem
    wrote on last edited by
    #1

    Hi,

    We try to integrate https://github.com/CopernicaMarketingSoftware/AMQP-CPP AMQP-CPP with QT

    in the pro file:

    LIBS +=-L/usr/local/lib/ -lamqpcpp -ldl -lev
    INCLUDEPATH += /usr/local/include/amqpcpp
    INCLUDEPATH += /usr/local/opt/openssl/include

    so all is good for building.

    I create a thread with movetothread :

    mongoUpdate::mongoUpdate(QObject *parent) :
    
        QObject(parent)
    {
        // create event loop
            auto *loop = EV_DEFAULT;
    
            // construct handler
            AMQP::LibEvHandler handler(loop);
    
            // create tcp connection
            AMQP::TcpConnection Aconnection(&handler, AMQP::Address("amqp://alpullu:alpullu@192.168.1.103/"));
    
            // create a channel
            AMQP::TcpChannel channel(&Aconnection);
            channel.onReady([&channel]() {
    
                    // declare an exchange
                    channel.declareExchange("myexchange");
    
                    // create aqueue
                    channel.declareQueue("myqueue");
    
                    // bind exchange to queue
                    channel.bindQueue("myexchange", "zalpullu", "routingkey");
                    for(int i = 0; i < 10; i++)
                            {
                                // publish and sleep to highlight the problem
                                channel.publish("myexchange", "routingkey", "hello-alpullu");
                            }
    });
            // declare an exchange
            channel.declareExchange("myexchange");
    
            // create aqueue
            channel.declareQueue("myqueue");
    
            // bind exchange to queue
            channel.bindQueue("myexchange", "zalpullu", "routingkey");
            for(int i = 0; i < 10; i++)
                    {
                        // publish and sleep to highlight the problem
                        channel.publish("myexchange", "routingkey", "hello-alpullu");
                    }
    

    I try to make a thread and connect through signal slot mechanism to send amqp message (rabbitMQ).

    it is not worked. not send the example message.

    Is there a simple QT project for AMQP-CPP to start working.?

    thanks

    jsulmJ 1 Reply Last reply
    0
    • R RahibeMeryem

      Hi,

      We try to integrate https://github.com/CopernicaMarketingSoftware/AMQP-CPP AMQP-CPP with QT

      in the pro file:

      LIBS +=-L/usr/local/lib/ -lamqpcpp -ldl -lev
      INCLUDEPATH += /usr/local/include/amqpcpp
      INCLUDEPATH += /usr/local/opt/openssl/include

      so all is good for building.

      I create a thread with movetothread :

      mongoUpdate::mongoUpdate(QObject *parent) :
      
          QObject(parent)
      {
          // create event loop
              auto *loop = EV_DEFAULT;
      
              // construct handler
              AMQP::LibEvHandler handler(loop);
      
              // create tcp connection
              AMQP::TcpConnection Aconnection(&handler, AMQP::Address("amqp://alpullu:alpullu@192.168.1.103/"));
      
              // create a channel
              AMQP::TcpChannel channel(&Aconnection);
              channel.onReady([&channel]() {
      
                      // declare an exchange
                      channel.declareExchange("myexchange");
      
                      // create aqueue
                      channel.declareQueue("myqueue");
      
                      // bind exchange to queue
                      channel.bindQueue("myexchange", "zalpullu", "routingkey");
                      for(int i = 0; i < 10; i++)
                              {
                                  // publish and sleep to highlight the problem
                                  channel.publish("myexchange", "routingkey", "hello-alpullu");
                              }
      });
              // declare an exchange
              channel.declareExchange("myexchange");
      
              // create aqueue
              channel.declareQueue("myqueue");
      
              // bind exchange to queue
              channel.bindQueue("myexchange", "zalpullu", "routingkey");
              for(int i = 0; i < 10; i++)
                      {
                          // publish and sleep to highlight the problem
                          channel.publish("myexchange", "routingkey", "hello-alpullu");
                      }
      

      I try to make a thread and connect through signal slot mechanism to send amqp message (rabbitMQ).

      it is not worked. not send the example message.

      Is there a simple QT project for AMQP-CPP to start working.?

      thanks

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @RahibeMeryem I don't see any call to moveToThread and I don't see any connect() calls...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RahibeMeryem
        wrote on last edited by
        #3

        movethrrad and the connect already in place. Working .

        I didt put here to make the code bigger.

        1 Reply Last reply
        0
        • Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @RahibeMeryem is a simpler Qt application (i.e. console app with all AMQP-CPP related code just in main.cpp) working fine?
          I'd create an Qt app based on examples from AMQP-CPP to be sure everything fits before jumping into the turbulent waters of threading...

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          Paul ColbyP 1 Reply Last reply
          0
          • Pablo J. RoginaP Pablo J. Rogina

            @RahibeMeryem is a simpler Qt application (i.e. console app with all AMQP-CPP related code just in main.cpp) working fine?
            I'd create an Qt app based on examples from AMQP-CPP to be sure everything fits before jumping into the turbulent waters of threading...

            Paul ColbyP Offline
            Paul ColbyP Offline
            Paul Colby
            wrote on last edited by
            #5

            Hi @Pablo-J.-Rogina,

            I'm not at all familiar with this library, but have worked quite a bit with the protocol.

            Not sure if this is the issue (or maybe just one of others), but where you have:

            // create aqueue
            channel.declareQueue("myqueue");
            
            // bind exchange to queue
            channel.bindQueue("myexchange", "zalpullu", "routingkey");
            

            You're binding a zalpullu queue, which is not the same as the queue you just created ('myqueue`) - was that the intention?

            Also, have you considered https://github.com/mbroadst/qamqp ? I haven't used it myself, but might be easier to integrate with a Qt project.

            Cheers.

            R 1 Reply Last reply
            0
            • Paul ColbyP Paul Colby

              Hi @Pablo-J.-Rogina,

              I'm not at all familiar with this library, but have worked quite a bit with the protocol.

              Not sure if this is the issue (or maybe just one of others), but where you have:

              // create aqueue
              channel.declareQueue("myqueue");
              
              // bind exchange to queue
              channel.bindQueue("myexchange", "zalpullu", "routingkey");
              

              You're binding a zalpullu queue, which is not the same as the queue you just created ('myqueue`) - was that the intention?

              Also, have you considered https://github.com/mbroadst/qamqp ? I haven't used it myself, but might be easier to integrate with a Qt project.

              Cheers.

              R Offline
              R Offline
              RahibeMeryem
              wrote on last edited by
              #6

              @Paul-Colby said in QT and AMQP-CPP sample:

              https://github.com/mbroadst/qamqp

              yes I already fixed after saw. AMQP-cpp using some kind of event handler to execute publish message. libev, libuv etc.

              I am not so friendly with them :).

              I nevet thouht that its so hard to communicate with rabbitMQ :(. In scala/java we have lived in a hevan :)

              1 Reply Last reply
              0
              • Pablo J. RoginaP Offline
                Pablo J. RoginaP Offline
                Pablo J. Rogina
                wrote on last edited by
                #7

                @RahibeMeryem please don't forget to mark your post as solved if your issue is done. Thanks.

                Upvote the answer(s) that helped you solve the issue
                Use "Topic Tools" button to mark your post as Solved
                Add screenshots via postimage.org
                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  RahibeMeryem
                  wrote on last edited by
                  #8

                  Still not solved.

                  Couldnt find a way to work / example AMQP-CPP through QT threads

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved