2 years ago

#59932

test-img

Vivek pkd

fast insertion in loop -mongodb make Application not responding

Iam using qtcreator 5, Database mongodb(mongocxx) . Below code is placed inside a loop ,loop works when there is data available in socket .Data reads fast from socket, when i put mongodb insertion code here it makes builded application not responding ,But the data is sending to mongodb without any problem.

Data can be see in Qt creater editor ..only the builded application cannot access (not responding ).

How to fix it????

code part:

in header file:
     mongocxx::client& conn1 = get_client();
     mongocxx::database db;
     db = conn1["ASSET_TRACKING"];

in Loop:
         if (k != -1)
                    {
                     // qDebug() << "value found at "<<k ;
    
                     qWarning("Got db conn");
    
                    switch(k)
                    {
                      case 0 :
                      {
                         std::vector<bsoncxx::document::value> documents;
                         documents.push_back(
                         bsoncxx::builder::stream::document{} <<"tag_ID"<< e.toStdString() <<"POSX"<<posx<<"POSY"<<posy<<"POSZ"<<posz<< finalize);
                         db["Tagdemo"].insert_many(documents);

mongodb

qt

qt-creator

mongo-cxx-driver

0 Answers

Your Answer

Accepted video resources