Exemplo n.º 1
0
        public void StoreTransferrableMessage(TransferrableMessage transferrableMessage)
        {
            if (transferrableMessage != null)
            {
                Message message = transferrableMessage.Message;
                lock (_mutex)
                {
                    if (_messages.ContainsKey(message.MessageId))
                    {
                        return;                                           //message already transferred
                    }
                    StoreMessage(transferrableMessage.Message, null);

                    //restore subscriptions
                    foreach (var clientSubscription in transferrableMessage.SubscribedClients)
                    {
                        SubscriptionInfo subscriptionInfo = new SubscriptionInfo();
                        subscriptionInfo.ClientId = clientSubscription;
                        subscriptionInfo.Type     = message.MessageMetaData.SubscriptionType;

                        //we assume that if receptionlist is not empty then message is assigned to single client
                        if (message.MessageMetaData.RecepientList != null && message.MessageMetaData.RecepientList.Count > 0)
                        {
                            subscriptionInfo.SubscriptionId = message.MessageMetaData.RecepientList.First <string>();
                        }

                        if (AssignMessageToSubscriber(subscriptionInfo, message))
                        {
                            RemoveFromPendingQueues(message);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        internal bool StoreTransferrableMessage(string topic, TransferrableMessage message)
        {
            Topic topicInstance = GetTopic(topic);

            if (topicInstance != null)
            {
                topicInstance.StoreTransferrableMessage(message);
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        public TransferrableMessage GetTransferrableMessage(string messageId)
        {
            TransferrableMessage transferrableMessage = null;

            lock (_mutex)
            {
                Message message = null;
                if (_messages.TryGetValue(messageId, out message))
                {
                    message = message.Clone() as Message;
                    transferrableMessage = new TransferrableMessage(message);

                    foreach (ClientSubscriptionManager client in message.MessageMetaData.Subscriptions)
                    {
                        transferrableMessage.AddSubscribedClientId(client.ClientID);
                    }
                }
            }

            return(transferrableMessage);
        }