コード例 #1
0
        public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest)
        {
            var request        = _binarySerializer.Deserialize <DeleteTopicForClusterRequest>(remotingRequest.Body);
            var requestService = new BrokerRequestService(_nameServerController);

            requestService.ExecuteActionToAllClusterBrokers(request.ClusterName, async remotingClient =>
            {
                var requestData      = _binarySerializer.Serialize(new DeleteTopicRequest(request.Topic));
                var remotingResponse = await remotingClient.InvokeAsync(new RemotingRequest((int)BrokerRequestCode.DeleteTopic, requestData), 30000);
                context.SendRemotingResponse(remotingResponse);
            });

            return(RemotingResponseFactory.CreateResponse(remotingRequest));
        }
        public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest)
        {
            var request = _binarySerializer.Deserialize<SetQueueNextConsumeOffsetForClusterRequest>(remotingRequest.Body);
            var requestService = new BrokerRequestService(_nameServerController);

            requestService.ExecuteActionToAllClusterBrokers(request.ClusterName, remotingClient =>
            {
                var requestData = _binarySerializer.Serialize(new SetQueueNextConsumeOffsetRequest(request.ConsumerGroup, request.Topic, request.QueueId, request.NextOffset));
                var remotingResponse = remotingClient.InvokeSync(new RemotingRequest((int)BrokerRequestCode.SetQueueNextConsumeOffset, requestData), 30000);
                if (remotingResponse.Code != ResponseCode.Success)
                {
                    throw new Exception(string.Format("SetQueueNextConsumeOffset failed, errorMessage: {0}", Encoding.UTF8.GetString(remotingResponse.Body)));
                }
            });

            return RemotingResponseFactory.CreateResponse(remotingRequest);
        }
        public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest)
        {
            var request        = _binarySerializer.Deserialize <SetQueueProducerVisibleForClusterRequest>(remotingRequest.Body);
            var requestService = new BrokerRequestService(_nameServerController);

            requestService.ExecuteActionToAllClusterBrokers(request.ClusterName, remotingClient =>
            {
                var requestData      = _binarySerializer.Serialize(new SetQueueProducerVisibleRequest(request.Topic, request.QueueId, request.Visible));
                var remotingResponse = remotingClient.InvokeSync(new RemotingRequest((int)BrokerRequestCode.SetQueueProducerVisible, requestData), 30000);
                if (remotingResponse.ResponseCode != ResponseCode.Success)
                {
                    throw new Exception(string.Format("SetQueueProducerVisible failed, errorMessage: {0}", Encoding.UTF8.GetString(remotingResponse.ResponseBody)));
                }
            });

            return(RemotingResponseFactory.CreateResponse(remotingRequest));
        }