本文整理汇总了C++中Subscription::cancel方法的典型用法代码示例。如果您正苦于以下问题:C++ Subscription::cancel方法的具体用法?C++ Subscription::cancel怎么用?C++ Subscription::cancel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscription
的用法示例。
在下文中一共展示了Subscription::cancel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: received
void Receiver::received(Message& message)
{
if (!(skipDups && isDuplicate(message))) {
bool eos = message.getData() == EOS;
if (!eos) std::cout << message.getData() << std::endl;
if (eos || ++processed == count) subscription.cancel();
}
}
示例2: received
void Listener::received(Message & message)
{
if (message.getData() == "That's all, folks!")
{
done = true;
if(verbosity > 0 )
{
cout << "Shutting down listener for "
<< message.getDestination() << endl;
cout << "Listener received "
<< count
<< " messages ("
<< received_twice.size()
<< " received_twice)"
<< endl;
}
subscription.cancel();
if ( verbosity > 0 )
cout << "LISTENER COMPLETED\n";
if ( ! gaps ) {
cout << "no gaps were detected\n";
cout << received_twice.size() << " messages were received twice.\n";
}
else {
cout << "gaps detected\n";
for ( unsigned int i = 0; i < received_twice.size(); ++ i )
cout << "received_twice "
<< received_twice[i]
<< endl;
}
} else {
uint sn = message.getHeaders().getAsInt("sn");
if (lastSn < sn) {
if (sn - lastSn > 1) {
cerr << "Error: gap in sequence between " << lastSn << " and " << sn << endl;
gaps = true;
}
lastSn = sn;
++count;
if ( ! ( count % reportFrequency ) ) {
if ( verbosity > 0 )
cout << "Listener has received "
<< count
<< " messages on queue "
<< queueName
<< endl;
}
} else {
received_twice.push_back ( sn );
}
}
}
示例3: receivedFromSource
void receivedFromSource(Message& message)
{
QPID_LOG(debug, "transfering " << (transfered+1) << " of " << expected);
message.getDeliveryProperties().setRoutingKey(destination);
async(sourceSubscription.getSession()).messageTransfer(arg::content=message);
if (++transfered == expected) {
QPID_LOG(info, "completed job: " << transfered << " messages shifted from " <<
source << " to " << destination);
sourceSubscription.accept(sourceSubscription.getUnaccepted());
sourceSubscription.getSession().txCommit();
sourceSubscription.cancel();
//grant credit to allow broker to send us another control message
controlSubscription.grantMessageCredit(1);
}
}
示例4: receivedFromControl
void receivedFromControl(Message& message)
{
if (message.getData() == "transfer") {
source = message.getHeaders().getAsString("src");
destination = message.getHeaders().getAsString("dest");
expected = message.getHeaders().getAsInt("count");
transfered = 0;
QPID_LOG(info, "received transfer request: " << expected << " messages to be shifted from " <<
source << " to " << destination);
subscribeToSource(controlSubscription.getSubscriptionManager());
} else if (message.getData() == "quit") {
QPID_LOG(info, "received quit request");
controlSubscription.cancel();
} else {
std::cerr << "Rejecting invalid message: " << message.getData() << std::endl;
controlSubscription.getSession().messageReject(SequenceSet(message.getId()));
}
}