void connection_ConnectionResumed(object sender, NmsConnectionEventArgs e) { var pooledConnection = sender as NmsPooledConnection; lock (this) this.connections.Add(pooledConnection); if (this.ConnectionResumed != null) this.ConnectionResumed(this, new NmsConnectionEventArgs(pooledConnection)); }
void connection_ConnectionInterrupted(object sender, NmsConnectionEventArgs e) { var pooledConnection = sender as NmsPooledConnection; lock (this.connections) this.connections.Remove(pooledConnection); lock (this.connectionsForCleanup) this.connectionsForCleanup.Add(pooledConnection); if (this.ConnectionInterrupted != null) this.ConnectionInterrupted(this, new NmsConnectionEventArgs(pooledConnection)); }
void connection_ConnectionResumed(object sender, NmsConnectionEventArgs e) { lock (this) { if (this.isInitialized) return; log.Info("[{0}] Resuming consumer #{1} on this connection.", e.Connection.ID, this.id); this.connection = (INmsConnection)sender; if (this.requestOnlyCallback != null) this.SetupRequestOnly(this.connection, this.destination, this.requestOnlyCallback, this.selector); else if (this.requestReplyCallback != null) this.SetupRequestReply(this.connection, this.destination, this.requestReplyCallback, this.selector); } }
/// <summary> /// Occurs when the underlying connection has been interrupted. /// </summary> void connection_ConnectionInterrupted(object sender, NmsConnectionEventArgs e) { lock (this) { if (this.connection != sender) return; log.Warn("[{0}] Consumer #{1}'s connection was lost. Attempting to recreate.", e.Connection.ID, this.id); if (this.requestOnlyCallback != null) this.consumer.Listener -= new MessageListener(this.RequestOnlyCallback); else if (this.requestReplyCallback != null) this.consumer.Listener -= new MessageListener(this.RequestReplyCallback); this.consumer.Dispose(); this.consumer = null; this.isInitialized = false; try { if (this.requestOnlyCallback != null) this.SetupRequestOnly(this.connection, this.destination, this.requestOnlyCallback, this.selector); else if (this.requestReplyCallback != null) this.SetupRequestReply(this.connection, this.destination, this.requestReplyCallback, this.selector); } catch (Exception ex) { log.Warn("[{0}] Failed to recreate consumer using this connection ({1}). Waiting for resume condition to restart.", e.Connection.ID, ex.Message); } } }
void connection_ConnectionResumed(object sender, NmsConnectionEventArgs e) { lock (this) { if (this.isInitialized) return; log.Info("[{0}] Resuming producer #{1} on this connection.", e.Connection.ID, this.id); this.connection = (INmsConnection)sender; this.Setup(this.connection, this.deliveryMode, this.isSynchronous); } }
void connection_ConnectionInterrupted(object sender, NmsConnectionEventArgs e) { lock (this) { if (this.connection != sender) return; this.isInitialized = false; this.isInitializedForSynchronous = false; this.asr.Reset(); log.Warn("[{0}] Producer #{1}'s connection was lost. Attempting to recreate.", e.Connection.ID, this.id); this.producer.Dispose(); this.producer = null; this.session.Dispose(); this.session = null; try { this.Setup(this.connection, this.deliveryMode, this.isSynchronous); } catch (Exception ex) { log.Warn("[{0}] Failed to recreate producer using this connection ({1}). Waiting for resume condition to restart.", e.Connection.ID, ex.Message); } } }