• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Remoting.RemotingRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ECommon.Remoting.RemotingRequest的典型用法代码示例。如果您正苦于以下问题:C# RemotingRequest类的具体用法?C# RemotingRequest怎么用?C# RemotingRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RemotingRequest类属于ECommon.Remoting命名空间,在下文中一共展示了RemotingRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: HandleRequest

 public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest)
 {
     var current = Interlocked.Increment(ref totalHandled);
     if (current == 1)
     {
         watch = Stopwatch.StartNew();
     }
     if (storeOption == "UnManagedMemory")
     {
         SaveMessage(remotingRequest.Body);
     }
     else if (storeOption == "ManagedMemory")
     {
         messageDictionary[remotingRequest.Sequence] = remotingRequest.Body;
     }
     else if (storeOption == "OnlyMapping")
     {
         messageDictionary[remotingRequest.Sequence] = remotingRequest.Sequence;
     }
     if (current % 10000 == 0)
     {
         Console.WriteLine("Handled request, size:{0}, count:{1}, timeSpent: {2}ms", remotingRequest.Body.Length, current, watch.ElapsedMilliseconds);
     }
     return new RemotingResponse(remotingRequest.Code, 10, remotingRequest.Type, response, remotingRequest.Sequence);
 }
开发者ID:johnwonder,项目名称:SimpleSocket,代码行数:25,代码来源:Program.cs


示例2: HandleRequest

        public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest request)
        {
            var queryTopicConsumeInfoRequest = _binarySerializer.Deserialize<QueryTopicConsumeInfoRequest>(request.Body);
            var topicConsumeInfoList = new List<TopicConsumeInfo>();

            if (!string.IsNullOrEmpty(queryTopicConsumeInfoRequest.GroupName))
            {
                var consumerGroups = _brokerController.ConsumerManager.QueryConsumerGroup(queryTopicConsumeInfoRequest.GroupName);
                foreach (var consumerGroup in consumerGroups)
                {
                    foreach (var topicConsumeInfo in GetTopicConsumeInfoForGroup(consumerGroup, queryTopicConsumeInfoRequest.Topic))
                    {
                        topicConsumeInfoList.Add(topicConsumeInfo);
                    }
                }
            }
            else
            {
                var consumerGroups = _brokerController.ConsumerManager.GetAllConsumerGroups();
                foreach (var consumerGroup in consumerGroups)
                {
                    foreach (var topicConsumeInfo in GetTopicConsumeInfoForGroup(consumerGroup, queryTopicConsumeInfoRequest.Topic))
                    {
                        topicConsumeInfoList.Add(topicConsumeInfo);
                    }
                }
            }

            var data = _binarySerializer.Serialize(topicConsumeInfoList);
            return new RemotingResponse((int)ResponseCode.Success, request.Sequence, data);
        }
开发者ID:WaylandGod,项目名称:equeue,代码行数:31,代码来源:QueryTopicConsumeInfoRequestHandler.cs


示例3: SendReplyAsync

        public void SendReplyAsync(int replyType, object replyData, string replyAddress)
        {
            _taskFactory.StartNew(obj =>
            {
                var request = obj as SendReplyRequest;
                try
                {
                    var remotingClientWrapper = GetRemotingClientWrapper(request.ReplyAddress);
                    if (remotingClientWrapper == null) return;

                    var message = _jsonSerializer.Serialize(request.ReplyData);
                    var body = Encoding.UTF8.GetBytes(message);
                    var remotingRequest = new RemotingRequest(request.ReplyType, body);
                    var getContextInfo = new Func<String>(() => string.Format("[replyAddress: {0}, replyType: {1}, message: {2}]", request.ReplyAddress, request.ReplyType, message));

                    _ioHelper.TryIOAction("SendCommandReply", getContextInfo, () =>
                    {
                        _ioHelper.TryIOAction(() =>
                        {
                            var remotingResponse = remotingClientWrapper.RemotingClient.InvokeSync(remotingRequest);
                            if (remotingResponse.Code != Constants.SuccessResponseCode)
                            {
                                throw new IOException("Send command reply failed, remotingResponseCode: {0}", remotingResponse.Code);
                            }
                            remotingClientWrapper.LastActiveTime = DateTime.Now;
                        }, "SendCommandReply");
                    }, 3);
                }
                catch (Exception ex)
                {
                    _logger.Error("Send command reply failed.", ex);
                }
            }, new SendReplyRequest(replyType, replyData, replyAddress));
        }
开发者ID:andyshao,项目名称:enode,代码行数:34,代码来源:SendReplyService.cs


示例4: ResponseFuture

 public ResponseFuture(RemotingRequest request, long timeoutMillis, TaskCompletionSource<RemotingResponse> taskSource)
 {
     Request = request;
     TimeoutMillis = timeoutMillis;
     _taskSource = taskSource;
     BeginTime = DateTime.Now;
 }
开发者ID:YqlZero,项目名称:ecommon,代码行数:7,代码来源:ResponseFuture.cs


示例5: HandleRequest

 public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest)
 {
     var topic = Encoding.UTF8.GetString(remotingRequest.Body);
     var queueIds = _queueService.GetQueues(topic).Select(x => x.QueueId).ToList();
     var data = Encoding.UTF8.GetBytes(string.Join(",", queueIds));
     return RemotingResponseFactory.CreateResponse(remotingRequest, data);
 }
开发者ID:haoas,项目名称:equeue,代码行数:7,代码来源:GetTopicQueueIdsForConsumerRequestHandler.cs


示例6: HandleRequest

 public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest)
 {
     var request = _binarySerializer.Deserialize<GetTopicAccumulateInfoListRequest>(remotingRequest.Body);
     var topicAccumulateInfoList = _clusterManager.GetTopicAccumulateInfoList(request);
     var data = _binarySerializer.Serialize(topicAccumulateInfoList);
     return RemotingResponseFactory.CreateResponse(remotingRequest, data);
 }
开发者ID:Aaron-Liu,项目名称:equeue,代码行数:7,代码来源:GetTopicAccumulateInfoListRequestHandler.cs


示例7: HandleRequest

        public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest)
        {
            var request = _binarySerializer.Deserialize<QueryTopicQueueInfoRequest>(remotingRequest.Body);
            var topicQueueInfoList = new List<TopicQueueInfo>();
            var topicList = !string.IsNullOrEmpty(request.Topic) ? new List<string> { request.Topic } : _queueService.GetAllTopics().ToList();

            foreach (var topic in topicList)
            {
                var queues = _queueService.QueryQueues(topic).ToList();
                foreach (var queue in queues)
                {
                    var topicQueueInfo = new TopicQueueInfo();
                    topicQueueInfo.Topic = queue.Topic;
                    topicQueueInfo.QueueId = queue.QueueId;
                    topicQueueInfo.QueueCurrentOffset = queue.CurrentOffset;
                    topicQueueInfo.QueueMinOffset = queue.GetMinQueueOffset();
                    topicQueueInfo.QueueMessageCount = queue.GetMessageRealCount();
                    topicQueueInfo.QueueMaxConsumedOffset = _offsetManager.GetMinOffset(queue.Topic, queue.QueueId);
                    topicQueueInfo.Status = queue.Status;
                    topicQueueInfoList.Add(topicQueueInfo);
                }
            }

            return RemotingResponseFactory.CreateResponse(remotingRequest, _binarySerializer.Serialize(topicQueueInfoList));
        }
开发者ID:huoxudong125,项目名称:equeue,代码行数:25,代码来源:QueryTopicQueueInfoRequestHandler.cs


示例8: HandleRequest

 public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest)
 {
     var request = _binarySerializer.Deserialize<GetClusterBrokersRequest>(remotingRequest.Body);
     var brokerInfoList = _clusterManager.GetClusterBrokers(request);
     var data = _binarySerializer.Serialize(brokerInfoList);
     return RemotingResponseFactory.CreateResponse(remotingRequest, data);
 }
开发者ID:Aaron-Liu,项目名称:equeue,代码行数:7,代码来源:GetClusterBrokersRequestHandler.cs


示例9: HandleRequest

        public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest request)
        {
            var queryTopicConsumeInfoRequest = _binarySerializer.Deserialize<QueryTopicQueueInfoRequest>(request.Body);
            var topicQueueInfoList = new List<TopicQueueInfo>();
            var topicList = !string.IsNullOrEmpty(queryTopicConsumeInfoRequest.Topic) ? new List<string> { queryTopicConsumeInfoRequest.Topic } : _messageService.GetAllTopics().ToList();

            foreach (var topic in topicList)
            {
                var queues = _messageService.QueryQueues(topic).ToList();
                foreach (var queue in queues)
                {
                    var queueMinOffset = queue.GetMinQueueOffset();
                    var topicQueueInfo = new TopicQueueInfo();
                    topicQueueInfo.Topic = queue.Topic;
                    topicQueueInfo.QueueId = queue.QueueId;
                    topicQueueInfo.QueueCurrentOffset = queue.CurrentOffset;
                    topicQueueInfo.QueueMinOffset = queueMinOffset != null ? queueMinOffset.Value : -1L;
                    topicQueueInfo.QueueMessageCount = queue.GetMessageRealCount();
                    topicQueueInfo.QueueMaxConsumedOffset = _offsetManager.GetMinOffset(queue.Topic, queue.QueueId);
                    topicQueueInfo.Status = queue.Status;
                    topicQueueInfoList.Add(topicQueueInfo);
                }
            }

            var data = _binarySerializer.Serialize(topicQueueInfoList);
            return new RemotingResponse((int)ResponseCode.Success, request.Sequence, data);
        }
开发者ID:WaylandGod,项目名称:equeue,代码行数:27,代码来源:QueryTopicQueueInfoRequestHandler.cs


示例10: HandleRequest

        public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest)
        {
            if (BrokerController.Instance.IsCleaning)
            {
                return BuildBrokerIsCleaningResponse(remotingRequest);
            }

            var request = DeserializePullMessageRequest(remotingRequest.Body);
            var topic = request.MessageQueue.Topic;
            var tags = request.Tags;
            var queueId = request.MessageQueue.QueueId;
            var pullOffset = request.QueueOffset;

            //如果消费者第一次过来拉取消息,则计算下一个应该拉取的位置,并返回给消费者
            if (pullOffset < 0)
            {
                var nextConsumeOffset = GetNextConsumeOffset(topic, queueId, request.ConsumerGroup, request.ConsumeFromWhere);
                return BuildNextOffsetResetResponse(remotingRequest, nextConsumeOffset);
            }

            //尝试拉取消息
            var pullResult = PullMessages(topic, tags, queueId, pullOffset, request.PullMessageBatchSize);

            //处理消息拉取结果
            if (pullResult.Status == PullStatus.Found)
            {
                return BuildFoundResponse(remotingRequest, pullResult.Messages);
            }
            else if (pullResult.Status == PullStatus.NextOffsetReset)
            {
                return BuildNextOffsetResetResponse(remotingRequest, pullResult.NextBeginOffset);
            }
            else if (pullResult.Status == PullStatus.QueueNotExist)
            {
                return BuildQueueNotExistResponse(remotingRequest);
            }
            else if (pullResult.Status == PullStatus.NoNewMessage)
            {
                if (request.SuspendPullRequestMilliseconds > 0)
                {
                    var pullRequest = new PullRequest(
                        remotingRequest,
                        request,
                        context,
                        DateTime.Now,
                        request.SuspendPullRequestMilliseconds,
                        ExecutePullRequest,
                        ExecutePullRequest,
                        ExecuteNoNewMessagePullRequest,
                        ExecuteReplacedPullRequest);
                    _suspendedPullRequestManager.SuspendPullRequest(pullRequest);
                    return null;
                }
                return BuildNoNewMessageResponse(remotingRequest);
            }
            else
            {
                throw new Exception("Invalid pull result status.");
            }
        }
开发者ID:RavenZZ,项目名称:equeue,代码行数:60,代码来源:PullMessageRequestHandler.cs


示例11: HandleRequest

 public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest request)
 {
     var pullMessageRequest = _binarySerializer.Deserialize<PullMessageRequest>(request.Body);
     var messages = _messageService.GetMessages(
         pullMessageRequest.MessageQueue.Topic,
         pullMessageRequest.MessageQueue.QueueId,
         pullMessageRequest.QueueOffset,
         pullMessageRequest.PullMessageBatchSize);
     if (messages.Count() > 0)
     {
         var pullMessageResponse = new PullMessageResponse(messages);
         var responseData = _binarySerializer.Serialize(pullMessageResponse);
         return new RemotingResponse((int)PullStatus.Found, request.Sequence, responseData);
     }
     else
     {
         var pullRequest = new PullRequest(
             request.Sequence,
             pullMessageRequest,
             context,
             DateTime.Now,
             SuspendPullRequestMilliseconds,
             ExecutePullRequest,
             ExecutePullRequest,
             ExecuteReplacedPullRequest);
         _brokerController.SuspendedPullRequestManager.SuspendPullRequest(pullRequest);
         return null;
     }
 }
开发者ID:kouweizhong,项目名称:equeue,代码行数:29,代码来源:PullMessageRequestHandler.cs


示例12: HandleRequest

        public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest)
        {
            var request = _binarySerializer.Deserialize<QueryConsumerInfoRequest>(remotingRequest.Body);
            var consumerInfoList = new List<ConsumerInfo>();

            if (!string.IsNullOrEmpty(request.GroupName))
            {
                var consumerGroups = _consumerManager.QueryConsumerGroup(request.GroupName);
                foreach (var consumerGroup in consumerGroups)
                {
                    foreach (var topicConsumeInfo in GetConsumerInfoForGroup(consumerGroup, request.Topic))
                    {
                        consumerInfoList.Add(topicConsumeInfo);
                    }
                }
            }
            else
            {
                var consumerGroups = _consumerManager.GetAllConsumerGroups();
                foreach (var consumerGroup in consumerGroups)
                {
                    foreach (var topicConsumeInfo in GetConsumerInfoForGroup(consumerGroup, request.Topic))
                    {
                        consumerInfoList.Add(topicConsumeInfo);
                    }
                }
            }

            return RemotingResponseFactory.CreateResponse(remotingRequest, _binarySerializer.Serialize(consumerInfoList));
        }
开发者ID:haoas,项目名称:equeue,代码行数:30,代码来源:QueryConsumerInfoRequestHandler.cs


示例13: HandleRequest

 public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest request)
 {
     var topic = Encoding.UTF8.GetString(request.Body);
     var queueIds = _messageService.GetQueueIdsForConsumer(topic);
     var data = Encoding.UTF8.GetBytes(string.Join(",", queueIds));
     return new RemotingResponse((int)ResponseCode.Success, request.Sequence, data);
 }
开发者ID:WaylandGod,项目名称:equeue,代码行数:7,代码来源:GetTopicQueueIdsForConsumerRequestHandler.cs


示例14: HandleRequest

 public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest)
 {
     var topic = Encoding.UTF8.GetString(remotingRequest.Body);
     var queueIds = _queueService.GetOrCreateQueues(topic, QueueStatus.Normal).Select(x => x.QueueId).ToList();
     var data = Encoding.UTF8.GetBytes(string.Join(",", queueIds));
     return new RemotingResponse((int)ResponseCode.Success, remotingRequest.Sequence, data);
 }
开发者ID:wangjiepower,项目名称:equeue,代码行数:7,代码来源:GetTopicQueueIdsForProducerRequestHandler.cs


示例15: HandleRequest

        public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest)
        {
            var request = MessageUtils.DecodeSendMessageRequest(remotingRequest.Body);
            var message = request.Message;
            var queueId = request.QueueId;
            var queue = _queueService.GetQueue(message.Topic, queueId);
            if (queue == null)
            {
                throw new QueueNotExistException(message.Topic, queueId);
            }

            //消息写文件需要加锁,确保顺序写文件
            MessageStoreResult result = null;
            lock (_syncObj)
            {
                var queueOffset = queue.NextOffset;
                var messageRecord = _messageStore.StoreMessage(queueId, queueOffset, message);
                queue.AddMessage(messageRecord.LogPosition);
                queue.IncrementNextOffset();
                result = new MessageStoreResult(messageRecord.MessageId, message.Code, message.Topic, queueId, queueOffset);
            }

            //如果需要立即通知所有消费者有新消息,则立即通知
            if (BrokerController.Instance.Setting.NotifyWhenMessageArrived)
            {
                _suspendedPullRequestManager.NotifyNewMessage(request.Message.Topic, result.QueueId, result.QueueOffset);
            }

            var data = MessageUtils.EncodeMessageStoreResult(result);
            return RemotingResponseFactory.CreateResponse(remotingRequest, data);
        }
开发者ID:haoas,项目名称:equeue,代码行数:31,代码来源:SendMessageRequestHandler.cs


示例16: HandleRequest

 public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest request)
 {
     var topic = Encoding.UTF8.GetString(request.Body);
     var queueCount = _messageService.GetTopicQueueCount(topic);
     var data = BitConverter.GetBytes(queueCount);
     return new RemotingResponse((int)ResponseCode.Success, request.Sequence, data);
 }
开发者ID:kouweizhong,项目名称:equeue,代码行数:7,代码来源:GetTopicQueueCountRequestHandler.cs


示例17: HandleRequest

        public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest)
        {
            if (BrokerController.Instance.IsCleaning)
            {
                throw new BrokerCleanningException();
            }

            var request = _binarySerializer.Deserialize<QueryTopicQueueInfoRequest>(remotingRequest.Body);
            var topicQueueInfoList = new List<TopicQueueInfo>();
            var queues = _queueStore.QueryQueues(request.Topic).ToList().OrderBy(x => x.Topic).ThenBy(x => x.QueueId);

            foreach (var queue in queues)
            {
                var topicQueueInfo = new TopicQueueInfo();
                topicQueueInfo.Topic = queue.Topic;
                topicQueueInfo.QueueId = queue.QueueId;
                topicQueueInfo.QueueCurrentOffset = queue.NextOffset - 1;
                topicQueueInfo.QueueMinOffset = queue.GetMinQueueOffset();
                topicQueueInfo.QueueMinConsumedOffset = _offsetStore.GetMinConsumedOffset(queue.Topic, queue.QueueId);
                topicQueueInfo.ProducerVisible = queue.Setting.ProducerVisible;
                topicQueueInfo.ConsumerVisible = queue.Setting.ConsumerVisible;
                topicQueueInfoList.Add(topicQueueInfo);
            }

            return RemotingResponseFactory.CreateResponse(remotingRequest, _binarySerializer.Serialize(topicQueueInfoList));
        }
开发者ID:a407121393,项目名称:equeue,代码行数:26,代码来源:QueryTopicQueueInfoRequestHandler.cs


示例18: HandleRequest

 public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest remotingRequest)
 {
     var request = _binarySerializer.Deserialize<QueryMessageRequest>(remotingRequest.Body);
     var total = 0;
     var messages = _messageStore.QueryMessages(request.Topic, request.QueueId, request.Code, request.RoutingKey, request.PageIndex, request.PageSize, out total).ToList();
     return new RemotingResponse((int)ResponseCode.Success, remotingRequest.Sequence, _binarySerializer.Serialize(new QueryMessageResponse(total, messages)));
 }
开发者ID:wangjiepower,项目名称:equeue,代码行数:7,代码来源:QueryMessageRequestHandler.cs


示例19: HandleRequest

 public RemotingResponse HandleRequest(IRequestHandlerContext context, RemotingRequest request)
 {
     var consumerData = _binarySerializer.Deserialize<ConsumerData>(request.Body);
     _brokerController.ConsumerManager.RegisterConsumer(
         consumerData.GroupName,
         new ClientChannel(consumerData.ConsumerId, context.Channel), consumerData.SubscriptionTopics);
     return null;
 }
开发者ID:kakashi006,项目名称:equeue,代码行数:8,代码来源:ConsumerHeartbeatRequestHandler.cs


示例20: ResponseFuture

 public ResponseFuture(RemotingRequest request, long timeoutMillis, TaskCompletionSource<RemotingResponse> requestTaskCompletionSource)
 {
     _beginTime = DateTime.Now;
     _timeoutMillis = timeoutMillis;
     _requestTaskCompletionSource = requestTaskCompletionSource;
     SendRequestSuccess = false;
     Request = request;
 }
开发者ID:jaohaohsuan,项目名称:ecommon,代码行数:8,代码来源:ResponseFuture.cs



注:本文中的ECommon.Remoting.RemotingRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DAL.dbEcustomEntities类代码示例发布时间:2022-05-24
下一篇:
C# ViewModels.NodeCategoryViewModel类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap