@@ -23,6 +23,7 @@ use bytes::Bytes;
2323use rocketmq_remoting:: code:: request_code:: RequestCode ;
2424use rocketmq_remoting:: net:: channel:: Channel ;
2525use rocketmq_remoting:: protocol:: body:: request:: lock_batch_request_body:: LockBatchRequestBody ;
26+ use rocketmq_remoting:: protocol:: body:: response:: lock_batch_response_body:: LockBatchResponseBody ;
2627use rocketmq_remoting:: protocol:: remoting_command:: RemotingCommand ;
2728use rocketmq_remoting:: protocol:: RemotingDeserializable ;
2829use rocketmq_remoting:: protocol:: RemotingSerializable ;
@@ -74,18 +75,17 @@ impl BatchMqHandler {
7475 addr_map. extend ( self . inner . broker_member_group . broker_addrs . clone ( ) ) ;
7576 addr_map. remove ( & self . inner . broker_config . broker_identity . broker_id ) ;
7677
77- let mut tasks = vec ! [ ] ;
78-
7978 let count_down_latch = CountDownLatch :: new ( addr_map. len ( ) as u32 ) ;
8079 let request_body = Bytes :: from ( request_body. encode ( ) ) ;
8180 let mq_lock_map_arc = Arc :: new ( Mutex :: new ( mq_lock_map. clone ( ) ) ) ;
8281 for ( _, broker_addr) in addr_map {
8382 let count_down_latch = count_down_latch. clone ( ) ;
8483 let broker_outer_api = self . inner . broker_out_api . clone ( ) ;
8584 let mq_lock_map = mq_lock_map_arc. clone ( ) ;
86- tasks. push ( tokio:: spawn ( async move {
85+ let request_body_cloned = request_body. clone ( ) ;
86+ tokio:: spawn ( async move {
8787 let result = broker_outer_api
88- . lock_batch_mq_async ( broker_addr, request_body . clone ( ) , 1000 )
88+ . lock_batch_mq_async ( broker_addr, request_body_cloned , 1000 )
8989 . await ;
9090 match result {
9191 Ok ( lock_ok_mqs) => {
@@ -99,7 +99,7 @@ impl BatchMqHandler {
9999 }
100100 }
101101 count_down_latch. count_down ( ) . await ;
102- } ) ) ;
102+ } ) ;
103103 }
104104 count_down_latch. wait_timeout ( Duration :: from_secs ( 2 ) ) . await ;
105105
@@ -111,15 +111,18 @@ impl BatchMqHandler {
111111 }
112112 }
113113 }
114- unimplemented ! ( "lock_natch_mq" )
114+ let response_body = LockBatchResponseBody {
115+ lock_ok_mq_set : lock_ok_mqset,
116+ } ;
117+ Some ( RemotingCommand :: create_response_command ( ) . set_body ( Some ( response_body. encode ( ) ) ) )
115118 }
116119
117120 pub async fn unlock_batch_mq (
118121 & mut self ,
119122 _channel : Channel ,
120123 _ctx : ConnectionHandlerContext ,
121124 _request_code : RequestCode ,
122- request : RemotingCommand ,
125+ _request : RemotingCommand ,
123126 ) -> Option < RemotingCommand > {
124127 unimplemented ! ( "unlockBatchMQ" )
125128 }
0 commit comments