Hi, I am new to this mailing list. I guess my question was already answered somewhere sometime before, I simply don't know where to look for.
To test my receiver, I want to write a unit-test application that simply sends a few messages. As simple as that. I wrote a sender that is implemented according to the recommendations in multithreaded<https://qpid.apache.org/releases/qpid-proton-0.32.0/proton/cpp/examples/multithreaded_client.cpp.html> example - since normally this is what I need. I thought of using it for my unit-test-sender as well but fund out that while running the container in a separate thread, letting the other thread add messages to be sent - I can't check if there are more messages to send before container.stop() is called. This is the schema of my unit-test: # cat -n Sources/Testing/RabbitMqTests/rabbitmq.tests.cpp 1 <snip> 3 #include "../OctSafetyListener/SafetyMessagingHandler.hpp" 4 5 using namespace std::chrono_literals; 6 7 8 int main(int argc, char* argv[]) { 9 <snip> 26 // create the message handler 27 SafetyMessagingHandler smh( <-- my message handler 28 input["url"].as<std::string>(), 29 input["queue"].as<std::string>() 30 ); 31 32 auto container = proton::container(smh); <-- build the container 33 34 // start themessage loop 35 std::thread rabbitPublishMsgLoop <-- create a working thread 36 { 37 [&container]() 38 { 39 try 40 { 41 container.run(); <-- run the container, this thread (rabbitPublishMsgLoop ) is here until an exception or stop() is called. 42 } 43 catch (const std::exception& e) 44 { 45 std::cerr << e.what() << std::endl; 46 } 47 } 48 }; 49 50 try 51 { 52 uint16_t msgCounter = 0; 53 uint16_t wsMsg[4] = {0}; 54 <snip> 56 for (int i = 0; i < 2; ++i) <-- two messages should be sent 57 { 58 wsMsg[0] = msgCounter++; 59 60 // read the message 61 StatusReportMsg msg(reinterpret_cast<uint8_t*>(&wsMsg)); <-- this is the body of the message (irrelevant to the question) 62 63 // publish 64 smh.PushStatusMessage(msg); <-- see below for the implementation of this function 65 } 66 67 } 68 catch (const std::exception& e) 69 { 70 std::cerr << e.what() << std::endl; 71 } <snip> 77 container.stop(); <-- this line is reached before the message is sent, also it throws an exception (the stop is not clean) 78 rabbitPublishMsgLoop.join(); 79 } 80 PushStatusMessage() looks like this: 20 auto workQueue = work_queue(); 21 22 if (workQueue) 23 { 24 workQueue->add( 25 [=]() 26 { <snip> 31 sender_.send(protonMsg); 32 }); 33 } Assume that I want to keep using my already implemented message_handler - is it possible to add something in such a way that stop will wait for the queue to be empty before stoping? If not - what is the best way to implement my original requirement (simply sends a few messages) Thanks, Ran.