private void attemptDeclarations(AmqpAdmin amqpAdmin) { ApplicationContext context = this.getApplicationContext(); if (context != null) { Set<String> queueNames = getQueueNamesAsSet(); Map<String, Queue> queueBeans = context.getBeansOfType(Queue.class); for (Entry<String, Queue> entry : queueBeans.entrySet()) { Queue queue = entry.getValue(); if (isMismatchedQueuesFatal() || (queueNames.contains(queue.getName()) && amqpAdmin.getQueueProperties(queue.getName()) == null)) { if (logger.isDebugEnabled()) { logger.debug("Redeclaring context exchanges, queues, bindings."); } amqpAdmin.initialize(); break; } } } }
private void attemptDeclarations(AmqpAdmin amqpAdmin) { ApplicationContext context = this.getApplicationContext(); if (context != null) { Set<String> queueNames = getQueueNamesAsSet(); Map<String, Queue> queueBeans = context.getBeansOfType(Queue.class); for (Entry<String, Queue> entry : queueBeans.entrySet()) { Queue queue = entry.getValue(); if (isMismatchedQueuesFatal() || (queueNames.contains(queue.getName()) && amqpAdmin.getQueueProperties(queue.getName()) == null)) { if (logger.isDebugEnabled()) { logger.debug("Redeclaring context exchanges, queues, bindings."); } amqpAdmin.initialize(); break; } } } }
protected void checkMismatchedQueues() { if (this.mismatchedQueuesFatal && this.amqpAdmin != null) { try { this.amqpAdmin.initialize(); } catch (AmqpConnectException e) { logger.info("Broker not available; cannot check queue declarations"); } catch (AmqpIOException e) { if (RabbitUtils.isMismatchedQueueArgs(e)) { throw new FatalListenerStartupException("Mismatched queues", e); } else { logger.info("Failed to get connection during start(): " + e); } } } else { try { Connection connection = getConnectionFactory().createConnection(); // NOSONAR if (connection != null) { connection.close(); } } catch (Exception e) { logger.info("Broker not available; cannot force queue declarations during start"); } } }
protected void checkMismatchedQueues() { if (this.mismatchedQueuesFatal && this.amqpAdmin != null) { try { this.amqpAdmin.initialize(); } catch (AmqpConnectException e) { logger.info("Broker not available; cannot check queue declarations"); } catch (AmqpIOException e) { if (RabbitUtils.isMismatchedQueueArgs(e)) { throw new FatalListenerStartupException("Mismatched queues", e); } else { logger.info("Failed to get connection during start(): " + e); } } } else { try { Connection connection = getConnectionFactory().createConnection(); // NOSONAR if (connection != null) { connection.close(); } } catch (Exception e) { logger.info("Broker not available; cannot force queue declarations during start"); } } }