/// <summary> /// Invokes the registered exception listener, if any. /// </summary> /// <param name="ex">The exception that arose during NMS processing.</param> /// <see cref="ExceptionListener"/> protected virtual void InvokeExceptionListener(Exception ex) { IExceptionListener exListener = ExceptionListener; if (exListener != null) { exListener.OnException(ex); } }
public InternalChainedExceptionListener(IExceptionListener internalListener, IExceptionListener userListener) { AddListener(internalListener); if (userListener != null) { AddListener(userListener); this.userListener = userListener; } }
//these are for starting and stoppign the script from an external source like //notepad++ public static void DirectInit(string f, string dir, string ll, IIOStream io, IExceptionListener listener) { IsConsole = false; IO = io; Init(listener); Settings.SetQuickDirectory(dir); Settings.SetLogLevel(ll); DirectRun(f); }
private MicroserviceInitializer AttachExceptionListeners() { FirstChanceExceptionListener = new FirstChanceExceptionListener(Logger); FirstChanceExceptionListener.Listen(); UnhandledExceptionListener = new UnhandledExceptionListener(Logger); UnhandledExceptionListener.Listen(); return(this); }
public static void Init(IExceptionListener el) { Settings.LoadSettings(); //on load set predefined functions and extensions to mitigate load from reflection predefinedFunctions = Utilities.GetPredefinedFunctions(); Compiler.PredefinedList = predefinedFunctions; ExtensionStack.Clear(); ExtensionStack.AddRange(Utilities.GetExtensions()); Compiler.ExceptionListener = el; ExceptionListener.stupidFix = true; // }
/// <summary> /// Prepares the connection before it is exposed. /// The default implementation applies ExceptionListener and client id. /// Can be overridden in subclasses. /// </summary> /// <param name="con">The Connection to prepare.</param> /// <exception cref="EMSException">if thrown by any EMS API methods.</exception> protected virtual void PrepareConnection(IConnection con) { if (ClientId != null) { con.ClientID = ClientId; } if (this.exceptionListener != null || this.reconnectOnException) { IExceptionListener listenerToUse = this.exceptionListener; if (reconnectOnException) { listenerToUse = new InternalChainedExceptionListener(this, listenerToUse); } con.ExceptionListener = listenerToUse; } }
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(); }
public void RegisteredExceptionListenerIsInvokedOnException() { SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer(); ISession session = A.Fake <ISession>(); A.CallTo(() => session.GetQueue(DESTINATION_NAME)).Returns(QUEUE_DESTINATION); A.CallTo(() => session.CreateConsumer(QUEUE_DESTINATION, null)).Returns(messageConsumer); // an exception is thrown, so the rollback logic is being applied here... A.CallTo(() => session.Transacted).Returns(false); IConnection connection = A.Fake <IConnection>(); connection.ExceptionListener += container.OnException; A.CallTo(() => connection.CreateSession(container.SessionAcknowledgeMode)).Returns(session); connection.Start(); IConnectionFactory connectionFactory = A.Fake <IConnectionFactory>(); A.CallTo(() => connectionFactory.CreateConnection()).Returns(connection); NMSException theException = new NMSException(EXCEPTION_MESSAGE); IExceptionListener exceptionListener = A.Fake <IExceptionListener>(); exceptionListener.OnException(theException); IMessage message = A.Fake <IMessage>(); 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); }
/// <summary> /// Adds the exception listener to the chain /// </summary> /// <param name="listener">The listener.</param> public void AddListener(IExceptionListener listener) { AssertUtils.ArgumentNotNull(listener, "listener", "ExceptionListener must not be null"); listeners.Add(listener); }
/// <summary> /// Adds the exception listener to the chain /// </summary> /// <param name="listener">The listener.</param> public void AddListener(IExceptionListener listener) { AssertUtils.ArgumentNotNull(listener, "listener", "ExceptionListener must not be null"); listeners.Add(listener); }
public InternalChainedExceptionListener(IExceptionListener internalListener, IExceptionListener userListener) { AddListener(internalListener); if (userListener != null) { AddListener(userListener); this.userListener = userListener; } }
public ConcordionBuilder WithExceptionListener(IExceptionListener eventRecorder) { // TODO - add code here for processing return this; }
public ConcordionBuilder WithExceptionListener(IExceptionListener eventRecorder) { // TODO - add code here for processing return(this); }