public object Dequeue() { object eventItem; QueuedItem item; Alachisoft.NCache.Common.Protobuf.Response response = null; Alachisoft.NCache.Common.Protobuf.BulkEventResponse bulkEvent = new Common.Protobuf.BulkEventResponse(); lock (this) { item = new QueuedItem(); for (int i = 1; i <= _eventBulkCount && _queue.Count > 0; i++) { eventItem = null; { eventItem = _queue.Dequeue(); item.Count = i; } if (eventItem == null) { break; } bulkEvent.eventList.Add((Alachisoft.NCache.Common.Protobuf.BulkEventItemResponse)eventItem); } if (bulkEvent.eventList.Count > 0) { response = new Common.Protobuf.Response(); response.bulkEventResponse = bulkEvent; response.responseType = Common.Protobuf.Response.Type.BULK_EVENT; } item.Item = (object)response; return(item); } }
public object Dequeue() { object eventItem; QueuedItem item; Alachisoft.NCache.Common.Protobuf.Response response = null; Alachisoft.NCache.Common.Protobuf.BulkEventResponse bulkEvent = new Common.Protobuf.BulkEventResponse(); lock (this) { item = new QueuedItem(); for (int i = 1; i <= _eventBulkCount && _queue.Count>0 ; i++) { eventItem = null; { eventItem = _queue.Dequeue(); item.Count = i; } if (eventItem == null) break; bulkEvent.eventList.Add((Alachisoft.NCache.Common.Protobuf.BulkEventItemResponse)eventItem); } if (bulkEvent.eventList.Count > 0) { response = new Common.Protobuf.Response(); response.bulkEventResponse = bulkEvent; response.responseType = Common.Protobuf.Response.Type.BULK_EVENT; } item.Item = (object)response; return item; } }
internal Alachisoft.NCache.Common.Protobuf.Response GetEvents(out bool hasMessages) { object eventItem; try { bool removeMessageFromQueue = false; if (_eventsQueue.Count > ServiceConfiguration.EventBulkCount) { removeMessageFromQueue = true; } else { if ((DateTime.Now - _lastEventCollectionTime).TotalMilliseconds > ServiceConfiguration.BulkEventCollectionInterval) { removeMessageFromQueue = true; } } if (removeMessageFromQueue) { if (_eventsQueue.Count > 0) { Alachisoft.NCache.Common.Protobuf.Response response = null; Alachisoft.NCache.Common.Protobuf.BulkEventResponse bulkEvent = new Common.Protobuf.BulkEventResponse(); for (int i = 0; i < ServiceConfiguration.EventBulkCount; i++) { eventItem = null; lock (_eventsQueue) { if (_eventsQueue.Count > 0) { eventItem = _eventsQueue.Dequeue(); if (SocketServer.IsServerCounterEnabled) { _connectionManager.PerfStatsColl.DecrementEventQueueCountStats(); } } } if (eventItem == null) { break; } bulkEvent.eventList.Add((Alachisoft.NCache.Common.Protobuf.BulkEventItemResponse)eventItem); } if (bulkEvent.eventList.Count > 0) { _lastEventCollectionTime = DateTime.Now; response = new Common.Protobuf.Response(); response.bulkEventResponse = bulkEvent; response.responseType = Common.Protobuf.Response.Type.BULK_EVENT; } hasMessages = _eventsQueue.Count > ServiceConfiguration.EventBulkCount; return(response); } } } catch (Exception ex) { if (SocketServer.IsServerCounterEnabled) { SocketServer.Logger.NCacheLog.Error("ClientManager.GetEvents", ex.ToString()); } } hasMessages = _eventsQueue.Count > ServiceConfiguration.EventBulkCount; return(null); }
internal Alachisoft.NCache.Common.Protobuf.Response GetEvents(out bool hasMessages) { object eventItem; try { bool removeMessageFromQueue = false; if (_eventsQueue.Count > _eventBulkCount) { removeMessageFromQueue = true; } else { if ((DateTime.Now - _lastEventCollectionTime).TotalMilliseconds > _bulkEventCollectionInterval) { removeMessageFromQueue = true; } } if (removeMessageFromQueue) { if (_eventsQueue.Count > 0) { Alachisoft.NCache.Common.Protobuf.Response response = null; Alachisoft.NCache.Common.Protobuf.BulkEventResponse bulkEvent = new Common.Protobuf.BulkEventResponse(); for (int i = 0; i < _eventBulkCount; i++) { eventItem = null; lock (_eventsQueue) { if (_eventsQueue.Count > 0) { eventItem = _eventsQueue.Dequeue(); if (SocketServer.IsServerCounterEnabled) _connectionManager.PerfStatsColl.DecrementEventQueueCountStats(); } } if (eventItem == null) break; bulkEvent.eventList.Add((Alachisoft.NCache.Common.Protobuf.BulkEventItemResponse)eventItem); } if (bulkEvent.eventList.Count > 0) { _lastEventCollectionTime = DateTime.Now; response = new Common.Protobuf.Response(); response.bulkEventResponse = bulkEvent; response.responseType = Common.Protobuf.Response.Type.BULK_EVENT; } hasMessages = _eventsQueue.Count > _eventBulkCount; return response; } } } catch (Exception ex) { if (SocketServer.IsServerCounterEnabled) SocketServer.Logger.NCacheLog.Error("ClientManager.GetEvents", ex.ToString()); } hasMessages = _eventsQueue.Count > _eventBulkCount; return null; }