public OnCallbackException ( RabbitMQ.Client.Events.CallbackExceptionEventArgs args ) : void | ||
args | RabbitMQ.Client.Events.CallbackExceptionEventArgs | |
return | void |
private void RecoverConsumers() { if (_disposed) { throw new ObjectDisposedException(GetType().FullName); } Dictionary <string, RecordedConsumer> recordedConsumersCopy; lock (_recordedConsumers) { recordedConsumersCopy = new Dictionary <string, RecordedConsumer>(_recordedConsumers); } foreach (KeyValuePair <string, RecordedConsumer> pair in recordedConsumersCopy) { string tag = pair.Key; RecordedConsumer cons = pair.Value; try { string newTag = cons.Recover(); lock (_recordedConsumers) { // make sure server-generated tags are re-added _recordedConsumers.Remove(tag); _recordedConsumers.Add(newTag, cons); } foreach (EventHandler <ConsumerTagChangedAfterRecoveryEventArgs> h in ConsumerTagChangeAfterRecovery?.GetInvocationList() ?? Array.Empty <Delegate>()) { try { var eventArgs = new ConsumerTagChangedAfterRecoveryEventArgs(tag, newTag); h(this, eventArgs); } catch (Exception e) { var args = new CallbackExceptionEventArgs(e); args.Detail["context"] = "OnConsumerRecovery"; _delegate.OnCallbackException(args); } } } catch (Exception cause) { string s = string.Format("Caught an exception while recovering consumer {0} on queue {1}: {2}", tag, cons.Queue, cause.Message); HandleTopologyRecoveryException(new TopologyRecoveryException(s, cause)); } } }
private bool TryRecoverConnectionDelegate() { try { var fh = endpoints.SelectOne(m_factory.CreateFrameHandler); m_delegate = new Connection(m_factory, false, fh, this.ClientProvidedName); return(true); } catch (Exception e) { ESLog.Error("Connection recovery exception.", e); // Trigger recovery error events var handler = m_connectionRecoveryError; if (handler != null) { var args = new ConnectionRecoveryErrorEventArgs(e); foreach (EventHandler <ConnectionRecoveryErrorEventArgs> h in handler.GetInvocationList()) { try { h(this, args); } catch (Exception ex) { var a = new CallbackExceptionEventArgs(ex); a.Detail["context"] = "OnConnectionRecoveryError"; m_delegate.OnCallbackException(a); } } } } return(false); }
private bool TryRecoverConnectionDelegate() { try { IFrameHandler fh = _endpoints.SelectOne(_factory.CreateFrameHandler); _delegate = new Connection(_factory, false, fh, ClientProvidedName); return(true); } catch (Exception e) { ESLog.Error("Connection recovery exception.", e); // Trigger recovery error events foreach (EventHandler <ConnectionRecoveryErrorEventArgs> h in ConnectionRecoveryError?.GetInvocationList() ?? Array.Empty <Delegate>()) { try { h(this, new ConnectionRecoveryErrorEventArgs(e)); } catch (Exception ex) { var a = new CallbackExceptionEventArgs(ex); a.Detail["context"] = "OnConnectionRecoveryError"; _delegate.OnCallbackException(a); } } } return(false); }
protected void RecoverQueues() { lock (this.m_recordedQueues) { var rqs = new Dictionary <string, RecordedQueue>(m_recordedQueues); foreach (var pair in rqs) { var oldName = pair.Key; var rq = pair.Value; try { rq.Recover(); var newName = rq.Name; // make sure server-named queues are re-added with // their new names. MK. this.DeleteRecordedQueue(oldName); this.RecordQueue(newName, rq); this.PropagateQueueNameChangeToBindings(oldName, newName); this.PropagateQueueNameChangeToConsumers(oldName, newName); if (this.m_queueNameChange != null) { foreach (QueueNameChangeAfterRecoveryEventHandler h in this.m_queueNameChange.GetInvocationList()) { try { h(oldName, newName); } catch (Exception e) { CallbackExceptionEventArgs args = new CallbackExceptionEventArgs(e); args.Detail["context"] = "OnQueueRecovery"; m_delegate.OnCallbackException(args); } } } } catch (Exception cause) { var s = String.Format("Caught an exception while recovering queue {0}: {1}", oldName, cause.Message); this.HandleTopologyRecoveryException(new TopologyRecoveryException(s, cause)); } } } }
protected void RecoverConsumers() { var dict = new Dictionary <string, RecordedConsumer>(m_recordedConsumers); foreach (KeyValuePair <string, RecordedConsumer> pair in dict) { string tag = pair.Key; RecordedConsumer cons = pair.Value; try { string newTag = cons.Recover(); lock (m_recordedConsumers) { // make sure server-generated tags are re-added m_recordedConsumers.Remove(tag); m_recordedConsumers.Add(newTag, cons); } if (m_consumerTagChange != null) { foreach (EventHandler <ConsumerTagChangedAfterRecoveryEventArgs> h in m_consumerTagChange.GetInvocationList()) { try { var eventArgs = new ConsumerTagChangedAfterRecoveryEventArgs(tag, newTag); h(this, eventArgs); } catch (Exception e) { var args = new CallbackExceptionEventArgs(e); args.Detail["context"] = "OnConsumerRecovery"; m_delegate.OnCallbackException(args); } } } } catch (Exception cause) { string s = String.Format("Caught an exception while recovering consumer {0} on queue {1}: {2}", tag, cons.Queue, cause.Message); HandleTopologyRecoveryException(new TopologyRecoveryException(s, cause)); } } }
public AutorecoveringConnection(ConnectionFactory factory, string clientProvidedName = null) { _factory = factory; ClientProvidedName = clientProvidedName; Action <Exception, string> onException = (exception, context) => _innerConnection.OnCallbackException(CallbackExceptionEventArgs.Build(exception, context)); _recoverySucceededWrapper = new EventingWrapper <EventArgs>("OnConnectionRecovery", onException); _connectionRecoveryErrorWrapper = new EventingWrapper <ConnectionRecoveryErrorEventArgs>("OnConnectionRecoveryError", onException); _consumerTagChangeAfterRecoveryWrapper = new EventingWrapper <ConsumerTagChangedAfterRecoveryEventArgs>("OnConsumerRecovery", onException); _queueNameChangeAfterRecoveryWrapper = new EventingWrapper <QueueNameChangedAfterRecoveryEventArgs>("OnQueueRecovery", onException); }
protected bool RecoverConnectionDelegate() { while (!ManuallyClosed) { try { var fh = endpoints.SelectOne(m_factory.CreateFrameHandler); m_delegate = new Connection(m_factory, false, fh, this.ClientProvidedName); return(true); } catch (Exception e) { ESLog.Error("Connection recovery exception.", e); // Trigger recovery error events var handler = m_connectionRecoveryError; if (handler != null) { var args = new ConnectionRecoveryErrorEventArgs(e); foreach (EventHandler <ConnectionRecoveryErrorEventArgs> h in handler.GetInvocationList()) { try { h(this, args); } catch (Exception ex) { var a = new CallbackExceptionEventArgs(ex); a.Detail["context"] = "OnConnectionRecoveryError"; m_delegate.OnCallbackException(a); } } } #if NETFX_CORE System.Threading.Tasks.Task.Delay(m_factory.NetworkRecoveryInterval).Wait(); #else Thread.Sleep(m_factory.NetworkRecoveryInterval); #endif } } return(false); }
protected async Task <bool> RecoverConnectionDelegate() { while (!ManuallyClosed) { try { var fh = await endpoints.SelectOne(m_factory.CreateFrameHandler); m_delegate = new Connection(m_factory, false, fh, this.ClientProvidedName); await m_delegate.Open(); return(true); } catch (Exception e) { ESLog.Error("Connection recovery exception.", e); // Trigger recovery error events var handler = m_connectionRecoveryError; if (handler != null) { var args = new ConnectionRecoveryErrorEventArgs(e); foreach (AsyncEventHandler <ConnectionRecoveryErrorEventArgs> h in handler.GetInvocationList()) { try { await h(this, args); } catch (Exception ex) { var a = new CallbackExceptionEventArgs(ex); a.Detail["context"] = "OnConnectionRecoveryError"; await m_delegate.OnCallbackException(a); } } } await Task.Delay(m_factory.NetworkRecoveryInterval); } } return(false); }
public AutorecoveringConnection(ConnectionConfig config, IEndpointResolver endpoints) { _config = config; _endpoints = endpoints; IFrameHandler fh = _endpoints.SelectOne(_config.FrameHandlerFactory); _innerConnection = new Connection(_config, fh); Action <Exception, string> onException = (exception, context) => _innerConnection.OnCallbackException(CallbackExceptionEventArgs.Build(exception, context)); _recoverySucceededWrapper = new EventingWrapper <EventArgs>("OnConnectionRecovery", onException); _connectionRecoveryErrorWrapper = new EventingWrapper <ConnectionRecoveryErrorEventArgs>("OnConnectionRecoveryError", onException); _consumerTagChangeAfterRecoveryWrapper = new EventingWrapper <ConsumerTagChangedAfterRecoveryEventArgs>("OnConsumerRecovery", onException); _queueNameChangeAfterRecoveryWrapper = new EventingWrapper <QueueNameChangedAfterRecoveryEventArgs>("OnQueueRecovery", onException); ConnectionShutdown += HandleConnectionShutdown; }
protected bool RecoverConnectionDelegate() { while (!ManuallyClosed) { try { var fh = endpoints.SelectOne(m_factory.CreateFrameHandler); m_delegate = new Connection(m_factory, false, fh, this.ClientProvidedName); return true; } catch (Exception e) { ESLog.Error("Connection recovery exception.", e); // Trigger recovery error events var handler = m_connectionRecoveryError; if (handler != null) { var args = new ConnectionRecoveryErrorEventArgs(e); foreach (EventHandler<ConnectionRecoveryErrorEventArgs> h in handler.GetInvocationList()) { try { h(this, args); } catch (Exception ex) { var a = new CallbackExceptionEventArgs(ex); a.Detail["context"] = "OnConnectionRecoveryError"; m_delegate.OnCallbackException(a); } } } #if NETFX_CORE System.Threading.Tasks.Task.Delay(m_factory.NetworkRecoveryInterval).Wait(); #else Thread.Sleep(m_factory.NetworkRecoveryInterval); #endif } } return false; }