public override MessageSubscription[] GetMessageSubscriptions(string server)
        {
            List <MessageSubscription> r = new List <MessageSubscription>();

            foreach (var queueName in MessageQueue.GetPrivateQueuesByMachine(server).
                     Where(q => q.QueueName.EndsWith(".subscriptions")).Select(q => q.QueueName))
            {
                MessageQueue q = Msmq.Create(server, queueName, QueueAccessMode.ReceiveAndAdmin);

                q.MessageReadPropertyFilter.Label = true;
                q.MessageReadPropertyFilter.Body  = true;

                try {
                    var publisher = q.GetDisplayName().Replace(".subscriptions", string.Empty);

                    foreach (var msg in q.GetAllMessages())
                    {
                        var itm = new MessageSubscription();
                        itm.FullName   = GetSubscriptionType(ReadMessageStream(msg.BodyStream));
                        itm.Name       = ParseClassName(itm.FullName);
                        itm.Subscriber = msg.Label;
                        itm.Publisher  = publisher;

                        r.Add(itm);
                    }
                } catch (Exception e) {
                    OnError("Error occured when getting subcriptions", e, true);
                }
            }

            return(r.ToArray());
        }
Exemple #2
0
        public MsmqMessageQueue(string serverName, Queue queue)
        {
            Queue = queue;

            Main = Msmq.Create(serverName, queue.Name, QueueAccessMode.ReceiveAndAdmin);

            _mainContent = Msmq.Create(serverName, queue.Name, QueueAccessMode.ReceiveAndAdmin);
            _mainContent.MessageReadPropertyFilter.ClearAll();
            _mainContent.MessageReadPropertyFilter.Body = true;


            if (Main.UseJournalQueue) // Error when trying to use FormatName, strange as it should work according to MSDN. Temp solution for now.
            {
                Journal = new MessageQueue(string.Format(@"{0}\Private$\{1};JOURNAL", serverName, queue.Name));

                _journalContent = new MessageQueue(string.Format(@"{0}\Private$\{1};JOURNAL", serverName, queue.Name));
                _journalContent.MessageReadPropertyFilter.ClearAll();
                _journalContent.MessageReadPropertyFilter.Body = true;
            }
        }
        public override MessageSubscription[] GetMessageSubscriptions(Dictionary <string, object> connectionSettings, IEnumerable <string> queues)
        {
            var server = connectionSettings[CS_SERVER] as string;
            List <MessageSubscription> r = new List <MessageSubscription>();

            var msmqQ = MessageQueue.GetPrivateQueuesByMachine(server).Where(q => q.QueueName.EndsWith(".subscriptions")).Select(q => q.QueueName);

            foreach (var queueName in queues)
            {
                var queueSubscr = queueName + ".subscriptions";

                if (msmqQ.Any(mq => mq.EndsWith(queueSubscr)))
                {
                    MessageQueue q = Msmq.Create(server, queueSubscr, QueueAccessMode.ReceiveAndAdmin);

                    q.MessageReadPropertyFilter.Label = true;
                    q.MessageReadPropertyFilter.Body  = true;

                    try {
                        foreach (var msg in q.GetAllMessages())
                        {
                            var itm = new MessageSubscription();
                            itm.FullName   = GetSubscriptionType(ReadMessageStream(msg.BodyStream));
                            itm.Name       = ParseClassName(itm.FullName);
                            itm.Subscriber = msg.Label;
                            itm.Publisher  = queueName;

                            r.Add(itm);
                        }
                    } catch (Exception e) {
                        OnError("Error occured when getting subcriptions", e, true);
                    }
                }
            }

            return(r.ToArray());
        }
Exemple #4
0
        public bool CanAccessQueue(Dictionary <string, object> connectionSettings, string queueName)
        {
            var queue = Msmq.Create(connectionSettings["server"] as string, queueName, QueueAccessMode.ReceiveAndAdmin);

            return(queue != null ? queue.CanRead : false);
        }
Exemple #5
0
        public bool CanAccessQueue(string server, string queueName)
        {
            var queue = Msmq.Create(server, queueName, QueueAccessMode.ReceiveAndAdmin);

            return(queue != null ? queue.CanRead : false);
        }