public void onCreate(Connection connection) { for (ConnectionListener delegate : this.delegates) { delegate.onCreate(connection); } }
public void onCreate(Connection connection) { for (ConnectionListener delegate : this.delegates) { delegate.onCreate(connection); } }
@Override public void addConnectionListener(ConnectionListener listener) { super.addConnectionListener(listener); // handles publishing sub-factory // If the connection is already alive we assume that the new listener wants to be notified if (this.connection.target != null) { listener.onCreate(this.connection); } }
@Override public void addConnectionListener(ConnectionListener listener) { super.addConnectionListener(listener); // handles publishing sub-factory // If the connection is already alive we assume that the new listener wants to be notified if (this.connection.target != null) { listener.onCreate(this.connection); } }
private void refreshProxyConnection(ChannelCachingConnectionProxy connection) { connection.destroy(); connection.notifyCloseIfNecessary(); connection.target = super.createBareConnection(); connection.closeNotified.set(false); getConnectionListener().onCreate(connection); if (logger.isDebugEnabled()) { logger.debug("Refreshed existing connection '" + connection + "'"); } }
private void refreshProxyConnection(ChannelCachingConnectionProxy connection) { connection.destroy(); connection.notifyCloseIfNecessary(); connection.target = super.createBareConnection(); connection.closeNotified.set(false); getConnectionListener().onCreate(connection); if (logger.isDebugEnabled()) { logger.debug("Refreshed existing connection '" + connection + "'"); } }
@Override public void setConnectionListeners(List<? extends ConnectionListener> listeners) { super.setConnectionListeners(listeners); // handles publishing sub-factory // If the connection is already alive we assume that the new listeners want to be notified if (this.connection.target != null) { this.getConnectionListener().onCreate(this.connection); } }
@Override public void setConnectionListeners(List<? extends ConnectionListener> listeners) { super.setConnectionListeners(listeners); // handles publishing sub-factory // If the connection is already alive we assume that the new listeners want to be notified if (this.connection.target != null) { this.getConnectionListener().onCreate(this.connection); } }
@Override public void addConnectionListener(ConnectionListener listener) { super.addConnectionListener(listener); // If the connection is already alive we assume that the new listener wants to be notified if (this.connection != null) { listener.onCreate(this.connection); } }
@Override public final Connection createConnection() throws AmqpException { if (this.stopped) { throw new AmqpApplicationContextClosedException( "The ApplicationContext is closed and the ConnectionFactory can no longer create connections."); } synchronized (this.connectionMonitor) { if (this.cacheMode == CacheMode.CHANNEL) { if (this.connection.target == null) { this.connection.target = super.createBareConnection(); // invoke the listener *after* this.connection is assigned if (!this.checkoutPermits.containsKey(this.connection)) { this.checkoutPermits.put(this.connection, new Semaphore(this.channelCacheSize)); } this.connection.closeNotified.set(false); getConnectionListener().onCreate(this.connection); } return this.connection; } else if (this.cacheMode == CacheMode.CONNECTION) { return connectionFromCache(); } } return null; // NOSONAR - never reach here - exceptions }
@Override public final Connection createConnection() throws AmqpException { if (this.stopped) { throw new AmqpApplicationContextClosedException( "The ApplicationContext is closed and the ConnectionFactory can no longer create connections."); } synchronized (this.connectionMonitor) { if (this.cacheMode == CacheMode.CHANNEL) { if (this.connection.target == null) { this.connection.target = super.createBareConnection(); // invoke the listener *after* this.connection is assigned if (!this.checkoutPermits.containsKey(this.connection)) { this.checkoutPermits.put(this.connection, new Semaphore(this.channelCacheSize)); } this.connection.closeNotified.set(false); getConnectionListener().onCreate(this.connection); } return this.connection; } else if (this.cacheMode == CacheMode.CONNECTION) { return connectionFromCache(); } } return null; // NOSONAR - never reach here - exceptions }
new AtomicInteger()); this.checkoutPermits.put(cachedConnection, new Semaphore(this.channelCacheSize)); getConnectionListener().onCreate(cachedConnection);
@Override public void setConnectionListeners(List<? extends ConnectionListener> listeners) { super.setConnectionListeners(listeners); // If the connection is already alive we assume that the new listeners want to be notified if (this.connection != null) { this.getConnectionListener().onCreate(this.connection); } }
@Test public void testJavaConfig() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class); Config.listener1.onCreate(Config.conn1); verify(Config.channel1).queueDeclare("foo", true, false, false, new HashMap<>()); verify(Config.channel1).exchangeDeclare("bar", "direct", true, false, true, new HashMap<String, Object>()); verify(Config.channel1).queueBind("foo", "bar", "foo", null); Config.listener2.onCreate(Config.conn2); verify(Config.channel2, never()) .queueDeclare(eq("foo"), anyBoolean(), anyBoolean(), anyBoolean(), isNull()); verify(Config.channel2, never()) .exchangeDeclare(eq("bar"), eq("direct"), anyBoolean(), anyBoolean(), anyBoolean(), anyMap()); verify(Config.channel2, never()).queueBind(eq("foo"), eq("bar"), eq("foo"), anyMap()); context.close(); }
public final Connection createConnection() throws AmqpException { synchronized (this.connectionMonitor) { if (this.connection == null) { Connection target = doCreateConnection(); this.connection = new SharedConnectionProxy(target); // invoke the listener *after* this.connection is assigned getConnectionListener().onCreate(target); } } return this.connection; }
admin.afterPropertiesSet(); assertNotNull(listener.get()); listener.get().onCreate(conn);
admin.afterPropertiesSet(); assertNotNull(listener.get()); listener.get().onCreate(conn);
admin.afterPropertiesSet(); assertNotNull(listener.get()); listener.get().onCreate(conn);
admin.afterPropertiesSet(); assertNotNull(listener.get()); listener.get().onCreate(conn);
@Override public Channel createChannel(boolean transactional) { if (!isOpen()) { synchronized (this) { if (!isOpen()) { logger.debug("Detected closed connection. Opening a new one before creating Channel."); target = createBareConnection(); getConnectionListener().onCreate(target); } } } Channel channel = target.createChannel(transactional); getChannelListener().onCreate(channel, transactional); return channel; }