@Override public void addMessagingClientFactory( final IMessagingClientFactory factory ) { this.logger.fine( "A new messaging factory was added: " + factory.getType()); synchronized( this ) { if( this.messagingClient.isDismissClient() && factory.getType().equals( this.messagingType )) { // This is the messaging factory we were expecting... // We can try to switch to this incoming factory right now! switchMessagingType( this.messagingType ); } } }
@Override public void addMessagingClientFactory( final IMessagingClientFactory factory ) { this.logger.fine( "A new messaging factory was added: " + factory.getType()); synchronized( this ) { if( this.messagingClient.isDismissClient() && factory.getType().equals( this.messagingType )) { // This is the messaging factory we were expecting... // We can try to switch to this incoming factory right now! switchMessagingType( this.messagingType ); } } }
private void resetClients( boolean shutdown ) { // Make fresh snapshots of the clients, as we don't want to reconfigure them while holding the lock. final ArrayList<RabbitMqClient> clients; synchronized( this ) { // Get the snapshot. clients = new ArrayList<>( this.clients ); // Remove the clients, new ones will be created if necessary. this.clients.clear(); } // Now reconfigure all the clients. for( RabbitMqClient client : clients ) { try { final ReconfigurableClient<?> reconfigurable = client.getReconfigurableClient(); // The reconfigurable can never be null. // If it was, a NPE would have been thrown when the Rabbit MQ client was created. if( shutdown ) reconfigurable.closeConnection(); else reconfigurable.switchMessagingType( RabbitMqConstants.FACTORY_RABBITMQ ); } catch( Throwable t ) { // Warn but continue to reconfigure the next clients! this.logger.warning("A client has thrown an exception on reconfiguration: " + client); Utils.logException(this.logger, new RuntimeException(t)); } } }