private void checkStartState() { if (!this.isRunning()) { try { Assert.state(this.startedLatch.await(START_WAIT_TIME, TimeUnit.SECONDS), "Container is not started - cannot adjust queues"); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new AmqpException("Interrupted waiting for start", e); } } }
@Override public String getMessage() { return super.getMessage() + this.failedQueues.toString(); }
if (e.getCause() instanceof AmqpApplicationContextClosedException) { this.logger.error("Application context is closed, terminating"); this.taskScheduler.schedule(this::stop, new Date());
if (e.getCause() instanceof AmqpApplicationContextClosedException) { this.logger.error("Application context is closed, terminating"); this.taskScheduler.schedule(this::stop, new Date());
private void checkStartState() { if (!this.isRunning()) { try { Assert.state(this.startedLatch.await(START_WAIT_TIME, TimeUnit.SECONDS), "Container is not started - cannot adjust queues"); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new AmqpException("Interrupted waiting for start", e); } } }
if (nextBackOff < 0 || e.getCause() instanceof AmqpApplicationContextClosedException) { DirectMessageListenerContainer.this.aborted = true; shutdown();
@Override public String getMessage() { return super.getMessage() + this.failedQueues.toString(); }
/** * Construct a template using the supplied uri. * @param uri the uri - must include user info, e.g. * "http://guest:guest@localhost:15672/api/". * @since 2.0 */ public RabbitManagementTemplate(String uri) { try { this.rabbitClient = new Client(uri); } catch (Exception e) { throw new AmqpException(e); } }
if (nextBackOff < 0 || e.getCause() instanceof AmqpApplicationContextClosedException) { DirectMessageListenerContainer.this.aborted = true; shutdown();
/** * Construct a template using the supplied uri. * @param uri the uri - must include user info, e.g. * "http://guest:guest@localhost:15672/api/". * @since 2.0 */ public RabbitManagementTemplate(String uri) { try { this.rabbitClient = new Client(uri); } catch (Exception e) { throw new AmqpException(e); } }
/** * Construct a template using the supplied uri. * @param uri the uri. * @param username the user. * @param password the password. */ public RabbitManagementTemplate(String uri, String username, String password) { try { this.rabbitClient = new Client(uri, username, password); } catch (Exception e) { throw new AmqpException(e); } }
/** * Construct a template using the supplied uri. * @param uri the uri. * @param username the user. * @param password the password. */ public RabbitManagementTemplate(String uri, String username, String password) { try { this.rabbitClient = new Client(uri, username, password); } catch (Exception e) { throw new AmqpException(e); } }
@Nullable private ChannelCachingConnectionProxy waitForConnection(long now) { ChannelCachingConnectionProxy cachedConnection = null; while (cachedConnection == null && System.currentTimeMillis() - now < this.channelCheckoutTimeout) { if (countOpenConnections() >= this.connectionLimit) { try { this.connectionMonitor.wait(this.channelCheckoutTimeout); cachedConnection = findIdleConnection(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new AmqpException("Interrupted while waiting for a connection", e); } } } return cachedConnection; }
/** * @param payloadClass the payload class. * @return the handler. */ protected InvocableHandlerMethod getHandlerForPayload(Class<? extends Object> payloadClass) { InvocableHandlerMethod handler = this.cachedHandlers.get(payloadClass); if (handler == null) { handler = findHandlerForPayload(payloadClass); if (handler == null) { throw new AmqpException("No method found for " + payloadClass); } this.cachedHandlers.putIfAbsent(payloadClass, handler); //NOSONAR setupReplyTo(handler); } return handler; }
@Nullable private ChannelCachingConnectionProxy waitForConnection(long now) { ChannelCachingConnectionProxy cachedConnection = null; while (cachedConnection == null && System.currentTimeMillis() - now < this.channelCheckoutTimeout) { if (countOpenConnections() >= this.connectionLimit) { try { this.connectionMonitor.wait(this.channelCheckoutTimeout); cachedConnection = findIdleConnection(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new AmqpException("Interrupted while waiting for a connection", e); } } } return cachedConnection; }
/** * @param payloadClass the payload class. * @return the handler. */ protected InvocableHandlerMethod getHandlerForPayload(Class<? extends Object> payloadClass) { InvocableHandlerMethod handler = this.cachedHandlers.get(payloadClass); if (handler == null) { handler = findHandlerForPayload(payloadClass); if (handler == null) { throw new AmqpException("No method found for " + payloadClass); } this.cachedHandlers.putIfAbsent(payloadClass, handler); //NOSONAR setupReplyTo(handler); } return handler; }
throw new AmqpException("Admin returned null QueueInfo");
throw new AmqpException("Admin returned null QueueInfo");
protected boolean matchHandlerMethod(Class<? extends Object> payloadClass, InvocableHandlerMethod handler) { Method method = handler.getMethod(); Annotation[][] parameterAnnotations = method.getParameterAnnotations(); // Single param; no annotation or not @Header if (parameterAnnotations.length == 1) { MethodParameter methodParameter = new MethodParameter(method, 0); if ((methodParameter.getParameterAnnotations().length == 0 || !methodParameter.hasParameterAnnotation(Header.class)) && methodParameter.getParameterType().isAssignableFrom(payloadClass)) { return true; } } boolean foundCandidate = false; for (int i = 0; i < parameterAnnotations.length; i++) { MethodParameter methodParameter = new MethodParameter(method, i); if ((methodParameter.getParameterAnnotations().length == 0 || !methodParameter.hasParameterAnnotation(Header.class)) && methodParameter.getParameterType().isAssignableFrom(payloadClass)) { if (foundCandidate) { throw new AmqpException("Ambiguous payload parameter for " + method.toGenericString()); } foundCandidate = true; } } return foundCandidate; }
protected InvocableHandlerMethod findHandlerForPayload(Class<? extends Object> payloadClass) { InvocableHandlerMethod result = null; for (InvocableHandlerMethod handler : this.handlers) { if (matchHandlerMethod(payloadClass, handler)) { if (result != null) { boolean resultIsDefault = result.equals(this.defaultHandler); if (!handler.equals(this.defaultHandler) && !resultIsDefault) { throw new AmqpException("Ambiguous methods for payload type: " + payloadClass + ": " + result.getMethod().getName() + " and " + handler.getMethod().getName()); } if (!resultIsDefault) { continue; // otherwise replace the result with the actual match } } result = handler; } } return result != null ? result : this.defaultHandler; }