private String getRequiredQueue() throws IllegalStateException { String name = this.defaultReceiveQueue; if (name == null) { throw new AmqpIllegalStateException("No 'queue' specified. Check configuration of RabbitTemplate."); } return name; }
@Test public void testBadCredentials() throws Exception { RabbitTemplate template = createTemplate(1); com.rabbitmq.client.ConnectionFactory cf = new com.rabbitmq.client.ConnectionFactory(); cf.setUsername("foo"); final CachingConnectionFactory connectionFactory = new CachingConnectionFactory(cf); try { this.doTest(MessageCount.LOW, Concurrency.LOW, TransactionMode.OFF, template, connectionFactory); fail("expected exception"); } catch (AmqpIllegalStateException e) { assertTrue("Expected FatalListenerStartupException", e.getCause() instanceof FatalListenerStartupException); } catch (Throwable t) { fail("expected FatalListenerStartupException:" + t.getClass() + ":" + t.getMessage()); } ((DisposableBean) template.getConnectionFactory()).destroy(); }
private String getRequiredQueue() throws IllegalStateException { String name = this.defaultReceiveQueue; if (name == null) { throw new AmqpIllegalStateException("No 'queue' specified. Check configuration of RabbitTemplate."); } return name; }
private MessageConverter getRequiredMessageConverter() throws IllegalStateException { MessageConverter converter = getMessageConverter(); if (converter == null) { throw new AmqpIllegalStateException( "No 'messageConverter' specified. Check configuration of RabbitTemplate."); } return converter; }
private MessageConverter getRequiredMessageConverter() throws IllegalStateException { MessageConverter converter = getMessageConverter(); if (converter == null) { throw new AmqpIllegalStateException( "No 'messageConverter' specified. Check configuration of RabbitTemplate."); } return converter; }
private void waitForConsumersToStart(Set<AsyncMessageProcessingConsumer> processors) { for (AsyncMessageProcessingConsumer processor : processors) { FatalListenerStartupException startupException = null; try { startupException = processor.getStartupException(); } catch (TimeoutException e) { throw RabbitExceptionTranslator.convertRabbitAccessException(e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw RabbitExceptionTranslator.convertRabbitAccessException(e); } if (startupException != null) { throw new AmqpIllegalStateException("Fatal exception on listener startup", startupException); } } }
private void waitForConsumersToStart(Set<AsyncMessageProcessingConsumer> processors) { for (AsyncMessageProcessingConsumer processor : processors) { FatalListenerStartupException startupException = null; try { startupException = processor.getStartupException(); } catch (TimeoutException e) { throw RabbitExceptionTranslator.convertRabbitAccessException(e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw RabbitExceptionTranslator.convertRabbitAccessException(e); } if (startupException != null) { throw new AmqpIllegalStateException("Fatal exception on listener startup", startupException); } } }
@RabbitListener(queues = {"customer.update"}) public void updateCustomer(String message) throws InterruptedException, IOException { Profile profile = objectMapper.readValue(message, Profile.class); try { // Update the customer service for the profile UpdateCustomerResponse response = customerClient.updateCustomerResponse(profile); if (!response.isSuccess()) { String errorMsg = String.format("Could not update customer from profile for %s", profile.getUsername()); log.error(errorMsg); throw new UnexpectedException(errorMsg); } } catch (Exception ex) { // Throw AMQP exception and redeliver the message throw new AmqpIllegalStateException("Customer service update failed", ex); } }
if (startupException != null) { this.consumers.remove(consumer); throw new AmqpIllegalStateException("Fatal exception on listener startup", startupException);
if (startupException != null) { this.consumers.remove(consumer); throw new AmqpIllegalStateException("Fatal exception on listener startup", startupException);
throw new AmqpIllegalStateException(rateLimitException.getMessage()); } catch (Exception ex) { log.info(ex);
throw new AmqpIllegalStateException(rateLimitException.getMessage()); } catch (Exception ex) { log.info(ex);
String methodName = getListenerMethodName(message, convertedMessage); if (methodName == null) { throw new AmqpIllegalStateException("No default listener method specified: " + "Either specify a non-null value for the 'defaultListenerMethod' property or " + "override the 'getListenerMethodName' method.");
String methodName = getListenerMethodName(message, convertedMessage); if (methodName == null) { throw new AmqpIllegalStateException("No default listener method specified: " + "Either specify a non-null value for the 'defaultListenerMethod' property or " + "override the 'getListenerMethodName' method.");
private <C> RabbitConverterFuture<C> convertSendAndReceive(String exchange, String routingKey, Object object, MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<C> responseType) { AsyncCorrelationData<C> correlationData = new AsyncCorrelationData<C>(messagePostProcessor, responseType, this.enableConfirms); if (this.container != null) { this.template.convertAndSend(exchange, routingKey, object, this.messagePostProcessor, correlationData); } else { MessageConverter converter = this.template.getMessageConverter(); if (converter == null) { throw new AmqpIllegalStateException( "No 'messageConverter' specified. Check configuration of RabbitTemplate."); } Message message = converter.toMessage(object, new MessageProperties()); this.messagePostProcessor.postProcessMessage(message, correlationData); ChannelHolder channelHolder = this.directReplyToContainer.getChannelHolder(); correlationData.future.setChannelHolder(channelHolder); sendDirect(channelHolder.getChannel(), exchange, routingKey, message, correlationData); } RabbitConverterFuture<C> future = correlationData.future; future.startTimer(); return future; }
private <C> RabbitConverterFuture<C> convertSendAndReceive(String exchange, String routingKey, Object object, MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<C> responseType) { AsyncCorrelationData<C> correlationData = new AsyncCorrelationData<C>(messagePostProcessor, responseType, this.enableConfirms); if (this.container != null) { this.template.convertAndSend(exchange, routingKey, object, this.messagePostProcessor, correlationData); } else { MessageConverter converter = this.template.getMessageConverter(); if (converter == null) { throw new AmqpIllegalStateException( "No 'messageConverter' specified. Check configuration of RabbitTemplate."); } Message message = converter.toMessage(object, new MessageProperties()); this.messagePostProcessor.postProcessMessage(message, correlationData); ChannelHolder channelHolder = this.directReplyToContainer.getChannelHolder(); correlationData.future.setChannelHolder(channelHolder); sendDirect(channelHolder.getChannel(), exchange, routingKey, message, correlationData); } RabbitConverterFuture<C> future = correlationData.future; future.startTimer(); return future; }