public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt)
 {
     UnprocessedMessage msg = new UnprocessedMessage();
     msg.DeliverBody = (BasicDeliverBody) evt.Method;
     msg.ChannelId = evt.ChannelId;
     _logger.Debug("New JmsDeliver method received");
     evt.ProtocolSession.UnprocessedMessageReceived(msg);
 }
        public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt) 
        {
            _logger.Debug("New Basic.Return method received");
            UnprocessedMessage msg = new UnprocessedMessage();
            msg.DeliverBody = null;
            msg.BounceBody = (BasicReturnBody) evt.Method;
            msg.ChannelId = evt.ChannelId;

            evt.ProtocolSession.UnprocessedMessageReceived(msg);
        }
Ejemplo n.º 3
0
        public void MessageReceived(UnprocessedMessage message)
        {
            if (_logger.IsDebugEnabled)
            {
                _logger.Debug("Message received in session with channel id " + _channelId);
            }

            if ( message.DeliverBody == null )
            {
                ReturnBouncedMessage(message);
            } 
            else
            {
                _queue.Enqueue(message);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handle a message that bounced from the server, creating
        /// the corresponding exception and notifying the connection about it
        /// </summary>
        /// <param name="message">Unprocessed message</param>
        private void ReturnBouncedMessage(UnprocessedMessage message)
        {
            try
            {
                AbstractQmsMessage bouncedMessage =
                    _messageFactoryRegistry.CreateMessage(0, false, message.ContentHeader, message.Bodies);

                int errorCode = message.BounceBody.ReplyCode;
                string reason = message.BounceBody.ReplyText;
                _logger.Debug("Message returned with error code " + errorCode + " (" + reason + ")");
                AMQException exception;

                if (errorCode == AMQConstant.NO_CONSUMERS.Code)
                {
                    exception = new AMQNoConsumersException(reason, bouncedMessage);
                } 
                else if (errorCode == AMQConstant.NO_ROUTE.Code)
                {
                    exception = new AMQNoRouteException(reason, bouncedMessage);
                }
                else
                {
                    exception = new AMQUndeliveredException(errorCode, reason, bouncedMessage);
                }
                
                _connection.ExceptionReceived(exception);
            } 
            catch (Exception ex)
            {
                _logger.Error("Caught exception trying to raise undelivered message exception (dump follows) - ignoring...", ex);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Deliver a message to the appropriate session, removing the unprocessed message
 /// from our map
 /// <param name="channelId">the channel id the message should be delivered to</param>
 /// <param name="msg"> the message</param>         
 private void DeliverMessageToAMQSession(ushort channelId, UnprocessedMessage msg)
 {
     AmqChannel channel = (AmqChannel) _channelId2SessionMap[channelId];
     channel.MessageReceived(msg);
     _channelId2UnprocessedMsgMap.Remove(channelId);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Callback invoked from the BasicDeliverMethodHandler when a message has been received.
 /// This is invoked on the MINA dispatcher thread.
 /// </summary>
 /// <param name="message">the unprocessed message</param>
 /// <exception cname="AMQException">if this was not expected</exception>         
 public void UnprocessedMessageReceived(UnprocessedMessage message)
 {
     _channelId2UnprocessedMsgMap[message.ChannelId] = message;
 }
Ejemplo n.º 7
0
        /**
         * Called from the AMQSession when a message has arrived for this consumer. This methods handles both the case
         * of a message listener or a synchronous receive() caller.
         *
         * @param messageFrame the raw unprocessed mesage
         * @param channelId    channel on which this message was sent
         */
        internal void NotifyMessage(UnprocessedMessage messageFrame, int channelId)
        {
            if (_logger.IsDebugEnabled)
            {
                _logger.Debug("notifyMessage called with message number " + messageFrame.DeliverBody.DeliveryTag);
            }
            try
            {
                AbstractQmsMessage jmsMessage = _messageFactory.CreateMessage((long)messageFrame.DeliverBody.DeliveryTag,
                                                                              messageFrame.DeliverBody.Redelivered,
                                                                              messageFrame.ContentHeader,
                                                                              messageFrame.Bodies);

                _logger.Debug("Message is of type: " + jmsMessage.GetType().Name);

                PreDeliver(jmsMessage);

                if (IsMessageListenerSet)
                {
                    // We do not need a lock around the test above, and the dispatch below as it is invalid
                    // for an application to alter an installed listener while the session is started.
#if __MonoCS__
                        _messageListener(jmsMessage);
#else
                    _messageListener.Invoke(jmsMessage);
#endif
                    PostDeliver(jmsMessage);
                }
                else
                {
                    _messageQueue.Enqueue(jmsMessage);
                }
            }
            catch (Exception e)
            {
                _logger.Error("Caught exception (dump follows) - ignoring...", e); // FIXME
            }
        }