/// <summary>
 /// Called when an exception occurs in message processing.
 /// </summary>
 /// <param name="exception">The exception.</param>
 public void OnException(EMSException exception)
 {
     foreach (IExceptionListener listener in listeners)
     {
         listener.OnException(exception);
     }
 }
        public void RegisteredExceptionListenerIsInvokedOnException()
        {
            SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();

            ISession session = (ISession) mocks.CreateMock(typeof (ISession));
            Expect.Call(session.CreateQueue(DESTINATION_NAME)).Return(QUEUE_DESTINATION);
            Expect.Call(session.CreateConsumer(QUEUE_DESTINATION, null)).Return(messageConsumer);
            // an exception is thrown, so the rollback logic is being applied here...
            Expect.Call(session.Transacted).Return(false);

            IConnection connection = (IConnection)mocks.CreateMock(typeof(IConnection));
            //connection.ExceptionListener += container.OnException;
            connection.ExceptionListener = container;
            Expect.Call(connection.CreateSession(false, container.SessionAcknowledgeMode)).Return(session);
            connection.Start();
            
            IConnectionFactory connectionFactory = (IConnectionFactory) mocks.CreateMock(typeof (IConnectionFactory));
            Expect.Call(connectionFactory.CreateConnection()).Return(connection);

            EMSException theException = new EMSException(EXCEPTION_MESSAGE);

            IExceptionListener exceptionListener = (IExceptionListener) mocks.CreateMock(typeof (IExceptionListener));
            exceptionListener.OnException(theException);

            //IMessage message = (IMessage) mocks.CreateMock(typeof (IMessage));
            TextMessage message = new TextMessage(null, "hello");
            mocks.ReplayAll();


            container.ConnectionFactory = connectionFactory;
            container.DestinationName = DESTINATION_NAME;
            container.MessageListener = new BadSessionAwareMessageListener(theException);
            container.ExceptionListener = exceptionListener;
            container.AfterPropertiesSet();

            // manually trigger an Exception with the above bad MessageListener...
            messageConsumer.SendMessage(message);

            mocks.VerifyAll();
        }
Esempio n. 3
0
 public override void OnException(TIBCO.EMS.EMSException e)
 {
     /* Handle any Exception related to EMS Connection */
     Console.Write("\n\n******** Exception :\n" + e.StackTrace);
 }
 public BadSessionAwareMessageListener(EMSException exception)
 {
     this.exception = exception;
 }
 public ConsumerErrorEventArgs(EMSException ex)
 {
     this.exception = ex;
 }
Esempio n. 6
0
 public void OnException(EMSException exception)
 {
     _service.Connect();
 }
        /// <summary>
        /// <see cref="IExceptionListener"/> implementation, invoked by the EMS provider in
	    /// case of connection failures. Re-initializes this listener container's
	    /// shared connection and its sessions and consumers.
        /// </summary>
        /// <param name="exception">The reported connection exception.</param>
        public void OnException(EMSException exception)
        {
            // First invoke the user-specific ExceptionListener, if any.
            InvokeExceptionListener(exception);
            // now try to recover the shared Connection and all consumers...
            if (logger.IsInfoEnabled)
            {
                logger.Info("Trying to recover from EMS Connection exception: " + exception);
            }
            try
            {
                lock (consumersMonitor)
                {
                    sessions = null;
                    consumers = null;
                }
                RefreshConnectionUntilSuccessful();
                InitializeConsumers();
                logger.Info("Successfully refreshed EMS Connection");
            }
            catch (RecoveryTimeExceededException)
            {
                throw;
            } catch (EMSException recoverEx)
            {
                logger.Debug("Failed to recover EMS Connection", recoverEx);
                logger.Error("Encountered non-recoverable EMSException", exception);
            }
        }
 /// <summary>
 /// Exception listener callback that renews the underlying single Connection.
 /// </summary>
 /// <param name="exception">The exception from the messaging infrastructure.</param>
 public void OnException(EMSException exception)
 {
     ResetConnection();
 }
 /// <summary>
 /// Invokes the registered exception listener, if any.
 /// </summary>
 /// <param name="ex">The exception that arose during EMS processing.</param>
 /// <see cref="ExceptionListener"/>
 protected virtual void InvokeExceptionListener(EMSException ex)
 {
     IExceptionListener exListener = ExceptionListener;
     if (exListener != null)
     {
         exListener.OnException(ex);
     }
 }
 public void OnException(EMSException exception)
 {
     count++;
 }
 public void OnException(EMSException exception)
 {
     logger.Info("********* Caught exception *************", exception);
 }
Esempio n. 12
0
 public void OnException(EMSException exception)
 {
     Connect();
 }
 public void OnException(EMSException e)
 {
     LOG.Error("Exception processing message", e);            
 }
Esempio n. 14
0
 public void FireExcpetionEvent(EMSException e)
 {
     exceptionListener.OnException(e);
 }
 public void OnException(EMSException ex)
 {
     // print the emsConnection exception status
     Utilities.WriteExceptionMessageToLog(ex, String.Format(@"Ошибка обработки очереди {0}", _emsInputQueueName));
 }