void SubscriberClientChannelHandler::messageReceived(const DuplexChannelPtr& channel, const PubSubResponsePtr& m) { if (m->has_message()) { boost::lock_guard<boost::shared_mutex> lock(queue_lock); LOG4CXX_DEBUG(logger, "Message received (topic:" << origData->getTopic() << ", subscriberId:" << origData->getSubscriberId() << ")"); if (this->handler.get()) { OperationCallbackPtr callback(new SubscriberConsumeCallback(client, shared_from_this(), origData, m)); this->handler->consume(origData->getTopic(), origData->getSubscriberId(), m->message(), callback); } else { queue.push_back(m); if (queue.size() >= (std::size_t)client->getConfiguration().getInt(Configuration::MAX_MESSAGE_QUEUE_SIZE, DEFAULT_MAX_MESSAGE_QUEUE_SIZE)) { channel->stopReceiving(); } } } else { HedwigClientChannelHandler::messageReceived(channel, m); } }
void SubscriberClientChannelHandler::messageReceived(const DuplexChannelPtr& channel, const PubSubResponsePtr& m) { if (m->has_message()) { TopicSubscriber ts(m->topic(), m->subscriberid()); // dispatch the message to target topic subscriber. deliverMessage(ts, m); return; } if (m->has_responsebody()) { const ResponseBody& respBody = m->responsebody(); if (respBody.has_subscriptionevent()) { const SubscriptionEventResponse& eventResp = respBody.subscriptionevent(); // dispatch the event TopicSubscriber ts(m->topic(), m->subscriberid()); handleSubscriptionEvent(ts, eventResp.event()); return; } } HedwigClientChannelHandler::messageReceived(channel, m); }