@@ -54,7 +54,8 @@ ConsumerImpl::ConsumerImpl(const ClientImplPtr client, const std::string& topic,
5454 const ExecutorServicePtr listenerExecutor /* = NULL by default */ ,
5555 bool hasParent /* = false by default */ ,
5656 const ConsumerTopicType consumerTopicType /* = NonPartitioned by default */ ,
57- Commands::SubscriptionMode subscriptionMode, Optional<MessageId> startMessageId)
57+ Commands::SubscriptionMode subscriptionMode,
58+ boost::optional<MessageId> startMessageId)
5859 : ConsumerImplBase(client, topic, Backoff(milliseconds(100 ), seconds(60 ), milliseconds(0 )), conf,
5960 listenerExecutor ? listenerExecutor : client->getListenerExecutorProvider ()->get()),
6061 waitingForZeroQueueSizeMessage(false ),
@@ -191,9 +192,8 @@ void ConsumerImpl::connectionOpened(const ClientConnectionPtr& cnx) {
191192 Lock lockForMessageId (mutexForMessageId_);
192193 // Update startMessageId so that we can discard messages after delivery restarts
193194 const auto startMessageId = clearReceiveQueue ();
194- const auto subscribeMessageId = (subscriptionMode_ == Commands::SubscriptionModeNonDurable)
195- ? startMessageId
196- : Optional<MessageId>::empty ();
195+ const auto subscribeMessageId =
196+ (subscriptionMode_ == Commands::SubscriptionModeNonDurable) ? startMessageId : boost::none;
197197 startMessageId_ = startMessageId;
198198 lockForMessageId.unlock ();
199199
@@ -373,11 +373,11 @@ void ConsumerImpl::triggerCheckExpiredChunkedTimer() {
373373 });
374374}
375375
376- Optional <SharedBuffer> ConsumerImpl::processMessageChunk (const SharedBuffer& payload,
377- const proto::MessageMetadata& metadata,
378- const MessageId& messageId,
379- const proto::MessageIdData& messageIdData,
380- const ClientConnectionPtr& cnx) {
376+ boost::optional <SharedBuffer> ConsumerImpl::processMessageChunk (const SharedBuffer& payload,
377+ const proto::MessageMetadata& metadata,
378+ const MessageId& messageId,
379+ const proto::MessageIdData& messageIdData,
380+ const ClientConnectionPtr& cnx) {
381381 const auto chunkId = metadata.chunk_id ();
382382 const auto uuid = metadata.uuid ();
383383 LOG_DEBUG (" Process message chunk (chunkId: " << chunkId << " , uuid: " << uuid
@@ -422,14 +422,14 @@ Optional<SharedBuffer> ConsumerImpl::processMessageChunk(const SharedBuffer& pay
422422 lock.unlock ();
423423 increaseAvailablePermits (cnx);
424424 trackMessage (messageId);
425- return Optional<SharedBuffer>:: empty () ;
425+ return boost::none ;
426426 }
427427
428428 chunkedMsgCtx.appendChunk (messageId, payload);
429429 if (!chunkedMsgCtx.isCompleted ()) {
430430 lock.unlock ();
431431 increaseAvailablePermits (cnx);
432- return Optional<SharedBuffer>:: empty () ;
432+ return boost::none ;
433433 }
434434
435435 LOG_DEBUG (" Chunked message completed chunkId: " << chunkId << " , ChunkedMessageCtx: " << chunkedMsgCtx
@@ -438,9 +438,9 @@ Optional<SharedBuffer> ConsumerImpl::processMessageChunk(const SharedBuffer& pay
438438 auto wholePayload = chunkedMsgCtx.getBuffer ();
439439 chunkedMessageCache_.remove (uuid);
440440 if (uncompressMessageIfNeeded (cnx, messageIdData, metadata, wholePayload, false )) {
441- return Optional<SharedBuffer>:: of ( wholePayload) ;
441+ return wholePayload;
442442 } else {
443- return Optional<SharedBuffer>:: empty () ;
443+ return boost::none ;
444444 }
445445}
446446
@@ -477,7 +477,7 @@ void ConsumerImpl::messageReceived(const ClientConnectionPtr& cnx, const proto::
477477 const auto & messageIdData = msg.message_id ();
478478 auto messageId = MessageIdBuilder::from (messageIdData).build ();
479479 auto optionalPayload = processMessageChunk (payload, metadata, messageId, messageIdData, cnx);
480- if (optionalPayload. is_present () ) {
480+ if (optionalPayload) {
481481 payload = optionalPayload.value ();
482482 } else {
483483 return ;
@@ -512,7 +512,7 @@ void ConsumerImpl::messageReceived(const ClientConnectionPtr& cnx, const proto::
512512 m.impl_ ->convertPayloadToKeyValue (config_.getSchema ());
513513
514514 const auto startMessageId = startMessageId_.get ();
515- if (isPersistent_ && startMessageId. is_present () &&
515+ if (isPersistent_ && startMessageId &&
516516 m.getMessageId ().ledgerId () == startMessageId.value ().ledgerId () &&
517517 m.getMessageId ().entryId () == startMessageId.value ().entryId () &&
518518 isPriorEntryIndex (m.getMessageId ().entryId ())) {
@@ -637,7 +637,7 @@ uint32_t ConsumerImpl::receiveIndividualMessagesFromBatch(const ClientConnection
637637 msg.impl_ ->setTopicName (batchedMessage.getTopicName ());
638638 msg.impl_ ->convertPayloadToKeyValue (config_.getSchema ());
639639
640- if (startMessageId. is_present () ) {
640+ if (startMessageId) {
641641 const MessageId& msgId = msg.getMessageId ();
642642
643643 // If we are receiving a batch message, we need to discard messages that were prior
@@ -921,10 +921,10 @@ void ConsumerImpl::messageProcessed(Message& msg, bool track) {
921921 * was
922922 * not seen by the application
923923 */
924- Optional <MessageId> ConsumerImpl::clearReceiveQueue () {
924+ boost::optional <MessageId> ConsumerImpl::clearReceiveQueue () {
925925 bool expectedDuringSeek = true ;
926926 if (duringSeek_.compare_exchange_strong (expectedDuringSeek, false )) {
927- return Optional<MessageId>:: of ( seekMessageId_.get () );
927+ return seekMessageId_.get ();
928928 } else if (subscriptionMode_ == Commands::SubscriptionModeDurable) {
929929 return startMessageId_.get ();
930930 }
@@ -943,12 +943,12 @@ Optional<MessageId> ConsumerImpl::clearReceiveQueue() {
943943 .ledgerId (nextMessageId.ledgerId ())
944944 .entryId (nextMessageId.entryId () - 1 )
945945 .build ();
946- return Optional<MessageId>:: of ( previousMessageId) ;
946+ return previousMessageId;
947947 } else if (lastDequedMessageId_ != MessageId::earliest ()) {
948948 // If the queue was empty we need to restart from the message just after the last one that has been
949949 // dequeued
950950 // in the past
951- return Optional<MessageId>:: of ( lastDequedMessageId_) ;
951+ return lastDequedMessageId_;
952952 } else {
953953 // No message was received or dequeued by this consumer. Next message would still be the
954954 // startMessageId
0 commit comments