You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I write a thread for processing rmq message.I use BaseConsumeMessage to waiting some message,my code like this:
AmqpClient::Channel::ptr_t channel = AmqpClient::Channel::Create(_serverUrl, _port, _userName, _password);
channel->DeclareQueue(this->_rmq_queque, false, true, false, false);
std::string consumer_tag = channel->BasicConsume(this->_rmq_queque, "");
while (1)
{
std::cout << "[y] wait for the message" << std::endl;
AmqpClient::Envelope::ptr_t envelope =
channel->BasicConsumeMessage(consumer_tag);
std::string buffer = envelope->Message()->Body();
std::cout << "[y] receve " << buffer << std::endl;
//quit the cyc when the quit var set true by main thread,
//******************* but ,it can't execute because waiting message
if (quit)
{
cout << "amq cmd rec thread over!" << endl;
break;
}
}
channel->BasicCancel(consumer_tag);
but ,I want to quit this thread when a signal send by main thread. but the BaseConsumeMessage blocking for waiting rmq message and can't processed any other code ,so,how can solve it ?
The text was updated successfully, but these errors were encountered:
Hi,
I write a thread for processing rmq message.I use BaseConsumeMessage to waiting some message,my code like this:
but ,I want to quit this thread when a signal send by main thread. but the BaseConsumeMessage blocking for waiting rmq message and can't processed any other code ,so,how can solve it ?
The text was updated successfully, but these errors were encountered: