List of usage examples for org.springframework.amqp AmqpIllegalStateException AmqpIllegalStateException
public AmqpIllegalStateException(String message)
From source file:org.kurento.rabbitmq.RabbitTemplate.java
private MessageConverter getRequiredMessageConverter() throws IllegalStateException { MessageConverter converter = this.getMessageConverter(); if (converter == null) { throw new AmqpIllegalStateException( "No 'messageConverter' specified. Check configuration of RabbitTemplate."); }//from ww w. ja v a 2 s. c o m return converter; }
From source file:org.kurento.rabbitmq.RabbitTemplate.java
private String getRequiredQueue() throws IllegalStateException { String name = this.queue; if (name == null) { throw new AmqpIllegalStateException("No 'queue' specified. Check configuration of RabbitTemplate."); }/* www .ja v a 2 s . c om*/ return name; }
From source file:org.springframework.amqp.rabbit.AsyncRabbitTemplate.java
@Override public <C> RabbitConverterFuture<C> convertSendAndReceive(String exchange, String routingKey, Object object, MessagePostProcessor messagePostProcessor) { CorrelationData correlationData = null; if (this.enableConfirms) { correlationData = new CorrelationData(null); }/*from w w w. jav a2s. c o m*/ CorrelationMessagePostProcessor<C> correlationPostProcessor = new CorrelationMessagePostProcessor<C>( messagePostProcessor, correlationData); if (this.container != null) { this.template.convertAndSend(exchange, routingKey, object, correlationPostProcessor, 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()); correlationPostProcessor.postProcessMessage(message); ChannelHolder channelHolder = this.directReplyToContainer.getChannelHolder(); correlationPostProcessor.getFuture().setChannelHolder(channelHolder); sendDirect(channelHolder.getChannel(), exchange, routingKey, message, correlationData); } RabbitConverterFuture<C> future = correlationPostProcessor.getFuture(); future.startTimer(); return future; }
From source file:org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.java
/** * Spring {@link ChannelAwareMessageListener} entry point. * <p>/*from ww w.ja v a 2 s. c om*/ * Delegates the message to the target listener method, with appropriate conversion of the message argument. If the * target method returns a non-null object, wrap in a Rabbit message and send it back. * @param message the incoming Rabbit message * @param channel the Rabbit channel to operate on * @throws Exception if thrown by Rabbit API methods */ public void onMessage(Message message, Channel channel) throws Exception { // Check whether the delegate is a MessageListener impl itself. // In that case, the adapter will simply act as a pass-through. Object delegate = getDelegate(); if (delegate != this) { if (delegate instanceof ChannelAwareMessageListener) { if (channel != null) { ((ChannelAwareMessageListener) delegate).onMessage(message, channel); return; } else if (!(delegate instanceof MessageListener)) { throw new AmqpIllegalStateException("MessageListenerAdapter cannot handle a " + "ChannelAwareMessageListener delegate if it hasn't been invoked with a Channel itself"); } } if (delegate instanceof MessageListener) { ((MessageListener) delegate).onMessage(message); return; } } // Regular case: find a handler method reflectively. Object convertedMessage = extractMessage(message); 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."); } // Invoke the handler method with appropriate arguments. Object[] listenerArguments = buildListenerArguments(convertedMessage); Object result = invokeListenerMethod(methodName, listenerArguments); if (result != null) { handleResult(result, message, channel); } else { logger.trace("No result object given - no result to handle"); } }