/// <summary>
 /// Message used to notify clients of a new message received. This is meant to be used by the messaging framework.
 /// </summary>
 /// <param name="notification"></param>
 internal void FireOnMessage(NetNotification notification)
 {
     if (OnMessage != null)
     {
         try
         {
             OnMessage(notification);
             if (notification.Headers != null)
             {
                 if (notification.Headers.ContainsKey("ACK_REQUIRED"))
                 {
                     notification.Headers["ACK_REQUIRED"].ToLower().Equals("false");
                     return;
                 }
             }
             if (autoAcknowledge && notification.DestinationType != NetAction.DestinationType.TOPIC)
             {
                 brokerClient.Acknowledge(notification);
             }
         }
         catch (Exception e)
         {
             log.Error("Notification failure", e);
         }
     }
 }
 /// <summary>
 /// Acknowledge a queue message.
 /// </summary>
 /// <param name="notification">The received notification object</param>
 public void Acknowledge(NetNotification notification)
 {
     if (notification.DestinationType != NetAction.DestinationType.TOPIC)
     {
         Acknowledge(notification.Destination, notification.Message.MessageId, null);
     }
 }
        /// <summary>
        /// Poll an message from a queue.
        /// </summary>
        /// <param name="queueName">Queue name (e.g. "/queue/foo").</param>
        /// <param name="timeout">Time, in miliseconds, before the agent stops waiting for a message, if the timeout is bigger than 0. If timeout is reached a TimeoutException is thrown. If the value is zero, than the agent will wait forever. A negative value means that the client doesn't want to wait if there are no messages is local agent's queue.</param>
        /// <param name="reserveTime">Message reserve time, in milliseconds. Polled messages are reserved, by default, for 15 minutes. If clients prefer a different reserve time, bigger or small, they can specify it.</param>
        /// <param name="acceptRequest">An AcceptRequest instance.</param>
        /// <returns>A NetNotification instance. In case of connection fail or if there are no messages in local agent's queue when timeout is negative null is returned.</returns>
        public NetNotification Poll(String queueName, long timeout, long reserveTime, AcceptRequest acceptRequest)
        {
            if (IsClosed())
            {
                return(null);
            }

            NetPoll   poll   = new NetPoll(queueName, timeout);
            NetAction action = new NetAction(NetAction.ActionType.POLL);

            action.PollMessage = poll;
            NetMessage netMessage = new NetMessage(action);

            if (reserveTime != -1)
            {
                netMessage.Headers.Add("RESERVE_TIME", reserveTime.ToString());
            }

            protocolHandler.HandleOutgoingMessage(netMessage, acceptRequest);
            NetNotification notification = protocolHandler.GetSyncMessage(queueName, netMessage);


            if (notification == BrokerProtocolHandler.UnblockNotification)
            {
                throw new TimeoutException();
            }

            if (notification == BrokerProtocolHandler.NoMessageNotification)
            {
                return(null);
            }

            return(notification);
        }
예제 #4
0
        public void OnMessageHandler(NetNotification notification)
        {
            lock(this)
            {
                Notifications.Add(notification);

                if(Notifications.Count == expectedMessages )
                {
                    ManualResetEvent.Set();
                }
            }
            if( ! this.actionType.Equals( NetAction.DestinationType.TOPIC ) )
            {
                client.Acknowledge(notification.Subscription, notification.Message.MessageId);
                Console.WriteLine("Acknowledge");
            }
        }
        private static NetNotification getNotificationMessage(Atom atom)
        {
            NetNotification notification = new NetNotification(atom.Action.Notification.Destination, translate(atom.Action.Notification.Destination_type), getBrokerMessage(atom.Action.Notification.Message), atom.Action.Notification.Subscription, atom.Header.Parameters);

            return(notification);
        }
예제 #6
0
 /// <summary>
 /// Message used to notify clients of a new message received. This is meant to be used by the messaging framework.
 /// </summary>
 /// <param name="notification"></param>
 internal void FireOnMessage(NetNotification notification)
 {
     if (OnMessage != null)
     {
         try
         {
             OnMessage(notification);
             if (notification.Headers != null)
             {
                 if (notification.Headers.ContainsKey("ACK_REQUIRED"))
                 {
                     notification.Headers["ACK_REQUIRED"].ToLower().Equals("false");
                     return;
                 }
             }
             if (autoAcknowledge && notification.DestinationType != NetAction.DestinationType.TOPIC)
             {
                 brokerClient.Acknowledge(notification);
             }
         }
         catch (Exception e)
         {
             log.Error("Notification failure", e);
         }
     }
 }
예제 #7
0
 /// <summary>
 /// Acknowledge a queue message.
 /// </summary>
 /// <param name="notification">The received notification object</param>
 public void Acknowledge(NetNotification notification)
 {
     if(notification.DestinationType != NetAction.DestinationType.TOPIC)
     {
         Acknowledge(notification.Destination, notification.Message.MessageId, null);
     }
 }
 private static NetNotification getNotificationMessage(Atom atom)
 {
     NetNotification notification = new NetNotification(atom.Action.Notification.Destination, translate(atom.Action.Notification.Destination_type), getBrokerMessage( atom.Action.Notification.Message ), atom.Action.Notification.Subscription, atom.Header.Parameters);
     return notification;
 }