Example #1
0
        public override bool StoreMessage(string topic, Messaging.Message message, OperationContext context)
        {
            Topic topicInstance = _topicManager.GetTopic(topic);
            bool  stored        = false;

            if (topicInstance != null)
            {
                StoreStatus status = _cacheStore.HasSpace(message, 0, true);

                _cacheStore.CheckIfCacheNearEviction();

                if (status == StoreStatus.HasSpace || status == StoreStatus.NearEviction)
                {
                    stored = topicInstance.StoreMessage(message, context);
                }


                if (_context.PerfStatsColl != null)
                {
                    _context.PerfStatsColl.SetCacheSize(Size);
                }

                if (status != StoreStatus.HasSpace)
                {
                    Evict();
                }

                if (status == StoreStatus.HasNotEnoughSpace)
                {
                    throw new OperationFailedException(ErrorCodes.Common.NOT_ENOUGH_ITEMS_EVICTED, ErrorMessages.GetErrorMessage(ErrorCodes.Common.NOT_ENOUGH_ITEMS_EVICTED));
                }
            }
            else
            {
                throw new OperationFailedException(ErrorCodes.PubSub.TOPIC_NOT_FOUND, ErrorMessages.GetErrorMessage(ErrorCodes.PubSub.TOPIC_NOT_FOUND, topic));
            }

            return(stored);
        }
Example #2
0
 private void OnMessageReceived(Messaging.Message msg)
 {
     MessageReceived(msg);
 }