Example #1
0
 protected void DoAMQPSendSync(Amqp.Message amqpMessage, TimeSpan timeout)
 {
     try
     {
         this.link.Send(amqpMessage, timeout);
         MsgsSentOnLink++;
     }
     catch (TimeoutException tex)
     {
         throw ExceptionSupport.GetTimeoutException(this.link, tex.Message);
     }
     catch (AmqpException amqpEx)
     {
         string messageId = MessageSupport.CreateNMSMessageId(amqpMessage.Properties.GetMessageId());
         throw ExceptionSupport.Wrap(amqpEx, "Failure to send message {1} on Producer {0}", this.Id, messageId);
     }
     catch (Exception ex)
     {
         Tracer.ErrorFormat("Encountered Error on sending message from Producer {0}. Message: {1}. Stack : {2}.", Id, ex.Message, ex.StackTrace);
         throw ExceptionSupport.Wrap(ex);
     }
 }
Example #2
0
        private static void HandleAsyncAMQPMessageOutcome(Amqp.ILink sender, Amqp.Message message, Outcome outcome, object state)
        {
            MessageProducer thisPtr          = state as MessageProducer;
            Exception       failure          = null;
            bool            isProducerClosed = (thisPtr.IsClosing || thisPtr.IsClosed);

            if (outcome.Descriptor.Name.Equals(MessageSupport.REJECTED_INSTANCE.Descriptor.Name) && !isProducerClosed)
            {
                string msgId = MessageSupport.CreateNMSMessageId(message.Properties.GetMessageId());
                Error  err   = (outcome as Amqp.Framing.Rejected).Error;
                failure = ExceptionSupport.GetException(err, "Msg {0} rejected", msgId);
            }
            else if (outcome.Descriptor.Name.Equals(MessageSupport.RELEASED_INSTANCE.Descriptor.Name) && !isProducerClosed)
            {
                string msgId = MessageSupport.CreateNMSMessageId(message.Properties.GetMessageId());
                Error  err   = new Error(ErrorCode.MessageReleased);
                err.Description = "AMQP Message has been release by peer.";
                failure         = ExceptionSupport.GetException(err, "Msg {0} released", msgId);
            }
            if (failure != null && !isProducerClosed)
            {
                thisPtr.OnException(failure);
            }
        }