コード例 #1
0
        /// <summary>
        /// Publishes all the messages held by this entry via their respective channels.
        /// </summary>
        public void FlushMessages()
        {
            ConcurrentDictionary <string, DeferredChannelMessage> channelMessageStore = _deferredChannelMessageStore;

            _deferredChannelMessageStore = new ConcurrentDictionary <string, DeferredChannelMessage>();

            foreach (KeyValuePair <string, DeferredChannelMessage> kvp in channelMessageStore)
            {
                string channelName             = kvp.Key;
                DeferredChannelMessage message = kvp.Value;

                Action <IDistributedMemoryManager, string, DeferredChannelMessage> flushChannelAction = TypeSpecificFlushActionDictionary.GetOrAdd(message.MessageType, GetTypeSpecificFlushAction);

                flushChannelAction(_distributedMemoryManager, channelName, message);
            }
        }
コード例 #2
0
        private static void FlushChannelMessages <T>(IDistributedMemoryManager distributedMemoryManager, string channelName, DeferredChannelMessage channelMessage)
        {
            if (channelMessage == null || channelMessage.Message == null)
            {
                return;
            }

            using (IChannel <T> channel = distributedMemoryManager.GetChannel <T>(channelName))
                using (new TenantAdministratorContext(channelMessage.TenantId))
                {
                    channel.Publish((T)channelMessage.Message, PublishMethod.Immediate, PublishOptions.FireAndForget);
                }
        }