@@ -2039,19 +2039,12 @@ bsl::shared_ptr<mqbi::Queue> ClusterQueueHelper::createQueueFactory(
20392039 d_allocator_p),
20402040 d_allocator_p);
20412041
2042+ // Create Local/Remote queue flavor
20422043 if (!isPrimary) {
20432044 queueSp->createRemote (
20442045 openQueueResponse.deduplicationTimeMs (),
20452046 d_clusterData_p->clusterConfig ().queueOperations ().ackWindowSize (),
20462047 &d_clusterData_p->stateSpPool ());
2047-
2048- if (context.d_domain_p ->registerQueue (errorDescription, queueSp) !=
2049- 0 ) {
2050- return 0 ; // RETURN
2051- }
2052-
2053- queueContext->d_liveQInfo .d_queue_sp = queueSp;
2054- d_queuesById[queueContext->d_liveQInfo .d_id ] = queueContext;
20552048 }
20562049 else {
20572050 // This is the primary of the queue.
@@ -2084,24 +2077,62 @@ bsl::shared_ptr<mqbi::Queue> ClusterQueueHelper::createQueueFactory(
20842077 // Queue must have been registered with storage manager before
20852078 // registering it with the domain, otherwise Queue.configure() will
20862079 // fail.
2080+ }
20872081
2088- if (context.d_domain_p ->registerQueue (errorDescription, queueSp) !=
2089- 0 ) {
2090- return 0 ; // RETURN
2091- }
2082+ // Register this queue to the dispatcher.
2083+ if (d_cluster_p->isRemote ()) {
2084+ d_cluster_p->dispatcher ()->registerClient (
2085+ queueSp.get (),
2086+ mqbi::DispatcherClientType::e_QUEUE);
2087+ }
2088+ else {
2089+ d_cluster_p->dispatcher ()->registerClient (
2090+ queueSp.get (),
2091+ mqbi::DispatcherClientType::e_QUEUE,
2092+ d_storageManager_p->processorForPartition (
2093+ queueContext->partitionId ()));
2094+ }
2095+
2096+ // Configure the queue
2097+ bdlma::LocalSequentialAllocator<1024 > localAllocator (d_allocator_p);
2098+ bmqu::MemOutStream error (&localAllocator);
20922099
2093- queueContext->d_liveQInfo .d_queue_sp = queueSp;
2094- // No need to insert in d_queuesById since those queues will never
2095- // be looked up by id (and all have k_PRIMARY_QUEUE_ID id).
2100+ int rc = queueSp->configure (error,
2101+ false , // isReconfigure
2102+ true ); // wait
2103+
2104+ if (rc != 0 ) {
2105+ // Queue.configure() failed.
2106+
2107+ BALL_LOG_ERROR << " Failure configuring queue '" << queueContext->uri ()
2108+ << " ': " << error.str () << " ." ;
2109+
2110+ errorDescription << error.str ();
2111+
2112+ // Discard the queue.
2113+ return 0 ; // RETURN
2114+ }
2115+
2116+ if (context.d_domain_p ->registerQueue (queueSp) != 0 ) {
2117+ // Discard the queue.
2118+ return 0 ; // RETURN
2119+ }
2120+
2121+ queueContext->d_liveQInfo .d_queue_sp = queueSp;
2122+
2123+ if (!isPrimary) {
2124+ d_queuesById[queueContext->d_liveQInfo .d_id ] = queueContext;
20962125 }
2126+ // else, no need to insert in d_queuesById since those queues will never
2127+ // be looked up by id (and all have k_PRIMARY_QUEUE_ID id).
20972128
20982129 if (!d_cluster_p->isRemote ()) {
20992130 d_clusterState_p->updatePartitionNumActiveQueues (
21002131 queueContext->partitionId (),
21012132 1 );
21022133 }
21032134
2104- return bsl::shared_ptr<mqbi::Queue>( queueSp) ;
2135+ return queueSp;
21052136}
21062137
21072138void ClusterQueueHelper::onHandleReleased (
0 commit comments