У меня есть собственный MessageListener из настраиваемой библиотеки
import org.springframework.amqp.core.*
public class Subscriber {
private SimpleMessageListenerContainer simpleMessageListenerContainer;
private ConnectionFactory rabbitConnectionFactory;
public final class ScruberMessageListner implements MessageListener {
@Override
public void onMessage(Message message) {
// TODO Auto-generated method stub
}
}
}
Когда я создаю подписчика, настраиваемая библиотека будет заботиться о запуске контейнера и управлении прослушивателем, а также о многих других дополнительных функциях.
@Configuration
public class BrokerSubscriberConfiguration {
@Bean
public Subscriber treatmentEventSubscriber(EventConsumer treatmentEventConsumer) {
return Subscriber.createInitialisedSubscriber(treatmentEventConsumer, configurations,
null, true);
}
}
@SpringBootApplication
@ComponentScan(basePackages = "com.fin.bc")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Приложение загружает прослушиватель сообщения, но выдает исключение при получении сообщения.
LogMessage:
SimpleConnection@2a76b80a [delegate=amqp://admin@10.15.190.17:5672/hydra.services, localPort= 50786], acknowledgeMode=AUTO local queue size=0
2020-05-08 15:22:16,251 DEBUG org.springframework.amqp.rabbit.listener.BlockingQueueConsumer [SimpleAsyncTaskExecutor-1] Received message: (Body:'[B@4037c15c(byte[4])' MessageProperties [headers={}, contentLength=0, receivedDeliveryMode=NON_PERSISTENT, redelivered=false, receivedExchange=, receivedRoutingKey=Hydra.clone.q2, deliveryTag=1, consumerTag=amq.ctag-50OU2ydRYIghmrPKncVtUw, consumerQueue=Hydra.clone.q2])
2020-05-08 15:22:16,369 WARN org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler [SimpleAsyncTaskExecutor-1] Execution of Rabbit message listener failed.
org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Listener threw exception
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.wrapToListenerExecutionFailedExceptionIfNeeded(AbstractMessageListenerContainer.java:1651)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1603)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.actualInvokeListener(AbstractMessageListenerContainer.java:1489)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:1466)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:1461)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:1410)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doReceiveAndExecute(SimpleMessageListenerContainer.java:870)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.receiveAndExecute(SimpleMessageListenerContainer.java:854)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$1600(SimpleMessageListenerContainer.java:78)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.mainLoop(SimpleMessageListenerContainer.java:1137)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1043)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Detected a Non-hex character at 1 or 2 position
at org.springframework.security.crypto.codec.Hex.decode(Hex.java:62)
at org.springframework.security.crypto.encrypt.HexEncodingTextEncryptor.decrypt(HexEncodingTextEncryptor.java:40)
at com.discover.cpp.mba.util.Encryptor.decrypt(Encryptor.java:32)
at com.discover.cpp.mba.Subscriber$SubscriberMessageListener.onMessage(Subscriber.java:521)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:1600)
... 10 common frames omitted
2020-05-08 15:22:16,372 DEBUG org.springframework.amqp.rabbit.listener.ContainerUtils [SimpleAsyncTaskExecutor-1] Rejecting messages (requeue=true)
Использует ли Rabbit Listener технику декодирования при обработке сообщение?