private void HandleNotification(NetMessage message)
        {
            string subscription = message.Action.NotificationMessage.Subscription;

            NetAction.DestinationType destType = message.Action.NotificationMessage.DestinationType;

            if (destType != NetAction.DestinationType.TOPIC)
            {
                lock (this.syncSubscriptions)
                {
                    string subs = message.Action.NotificationMessage.Subscription;
                    if (syncSubscriptions.ContainsKey(subscription))
                    {
                        PollRequest request = syncSubscriptions[subs];
                        request.Handover.Offer(message.Action.NotificationMessage);
                        return;
                    }
                }
            }

            lock (subscriptions)
            {
                IDictionary <string, Subscription> destSubscriptions = subscriptions[destType == NetAction.DestinationType.TOPIC ? NetAction.DestinationType.TOPIC : NetAction.DestinationType.QUEUE];

                if (destSubscriptions.ContainsKey(subscription))
                {
                    destSubscriptions[subscription].FireOnMessage(message.Action.NotificationMessage);
                }
                else
                {
                    DealWithException(new UnexpectedMessageException("No registered subscribers for received message.", message));
                }
            }
        }
 public NotificationHandler(BrokerClient client, NetAction.DestinationType actionType, int expectedMessages)
 {
     this.client = client;
     this.actionType = actionType;
     this.expectedMessages = expectedMessages;
     this.Notifications = new List<NetNotification>();
     this.ManualResetEvent = new ManualResetEvent(false);
 }
 public NotificationHandler(BrokerClient client, NetAction.DestinationType actionType, int expectedMessages)
 {
     this.client           = client;
     this.actionType       = actionType;
     this.expectedMessages = expectedMessages;
     this.Notifications    = new List <NetNotification>();
     this.ManualResetEvent = new ManualResetEvent(false);
 }
        private static DestinationType translate(NetAction.DestinationType destination)
        {
            switch (destination)
            {
            case NetAction.DestinationType.QUEUE: return(DestinationType.QUEUE);

            case NetAction.DestinationType.TOPIC: return(DestinationType.TOPIC);

            case NetAction.DestinationType.VIRTUAL_QUEUE: return(DestinationType.VIRTUAL_QUEUE);
            }
            throw new Exception("Unexpected DestinationType while marshalling message " + destination.ToString());
        }
 internal NetNotification(string destination, NetAction.DestinationType destinationType, NetBrokerMessage message, string subscription, IDictionary <string, string> headers)
 {
     this.destination     = destination;
     this.destinationType = destinationType;
     this.message         = message;
     if (subscription == null)
     {
         this.subscription = "";
     }
     else
     {
         this.subscription = subscription;
     }
     this.headers = headers;
 }
        private static void PublishMessages(BrokerClient brokerClient, string destination, int numberOfMessages, NetAction.DestinationType destinationType)
        {
            //string message = "Hello, how are you?";
            int i = 0;

            while ((numberOfMessages--) != 0)
            {
                System.Console.WriteLine("Publishing message");
                NetBrokerMessage brokerMessage = new NetBrokerMessage(System.Text.Encoding.UTF8.GetBytes((i++).ToString()));
                if (destinationType == NetAction.DestinationType.TOPIC)
                {
                    brokerClient.Publish(brokerMessage, destination);
                }
                else
                {
                    brokerClient.Enqueue(brokerMessage, destination);
                }
                System.Threading.Thread.Sleep(50);
            }
        }
 public Subscription(string destinationPattern, NetAction.DestinationType destinationType)
 {
     this.destinationPattern = destinationPattern;
     this.destinationType    = destinationType;
 }
Example #8
0
 public Subscription(string destinationPattern, NetAction.DestinationType destinationType)
 {
     this.destinationPattern = destinationPattern;
     this.destinationType = destinationType;
 }
Example #9
0
 public NetUnsubscribe(string destination, NetAction.DestinationType destinationType)
 {
     this.destination = destination;
     this.destinationType = destinationType;
 }
Example #10
0
 public NetPublish(string destination, NetAction.DestinationType destinationType, NetBrokerMessage message)
 {
     this.destinationType = destinationType;
     this.destination = destination;
     this.message = message;
 }
Example #11
0
 internal NetNotification(string destination, NetAction.DestinationType destinationType, NetBrokerMessage message, string subscription, IDictionary<string, string> headers)
 {
     this.destination = destination;
     this.destinationType = destinationType;
     this.message = message;
     if (subscription == null)
         this.subscription = "";
     else
         this.subscription = subscription;
     this.headers = headers;
 }
 public NetUnsubscribe(string destination, NetAction.DestinationType destinationType)
 {
     this.destination     = destination;
     this.destinationType = destinationType;
 }
 public NetPublish(string destination, NetAction.DestinationType destinationType, NetBrokerMessage message)
 {
     this.destinationType = destinationType;
     this.destination     = destination;
     this.message         = message;
 }