Spring RabbitMQ 无效的监听器
Spring RabbitMQ invalid listener
我是 Spring RabbitMQ 的新手。我正在尝试将我的 ChatMesssage 对象发送到 RabbitMQ,但是在配置 RabbitMQ 期间,我收到以下错误:
org.springframework.amqp.rabbit.listener.exception.FatalListenerExecutionException: Invalid listener
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1142)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Failed to invoke target method 'handleMessage' with argument type = [class [B], value = [{[B@6bced6b0}]
at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.invokeListenerMethod(MessageListenerAdapter.java:348)
at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.onMessage(MessageListenerAdapter.java:253)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:756)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:679)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access[=13=]1(SimpleMessageListenerContainer.java:83)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.invokeListener(SimpleMessageListenerContainer.java:170)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.invokeListener(SimpleMessageListenerContainer.java:1257)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener
兔子配置Class:
@Bean
TopicExchange directExchange(){
return new TopicExchange(MessagingBusNamespace.CHAT_MESSAGE_TOPIC_EXCHANGE);
}
@Bean
Binding binding(final Queue queue, final Exchange exchange){
return BindingBuilder.bind(queue).to(exchange).with(MessagingBusNamespace.ROUTE_KEY).noargs();
}
@Bean
HTTPChatMessageReceiver receiver(){
return new HTTPChatMessageReceiver();
}
@Bean
MessageListenerAdapter messageListenerAdapter(){
return new MessageListenerAdapter(receiver(), "handleMessage");
}
@Bean
SimpleMessageListenerContainer simpleMessageListenerContainer(final ConnectionFactory connectionFactory,
final MessageListenerAdapter messageListenerAdapter){
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.setQueueNames(MessagingBusNamespace.CHAT_MESSAGE_QUEUE);
container.setMessageListener(messageListenerAdapter);
return container;
}
处理程序 class :
public class HTTPChatMessageReceiver {
public HTTPChatMessageReceiver() {
// TODO Auto-generated constructor stub
}
public void handleMessage(ChatMessage message) {
}
}
终于找到问题了。该问题与 MessagingListenerAdapter 无关。这与我如何定义队列名称有关。
如果我声明队列如 "queue.chat",Spring 将抛出上述异常。
当我将队列名称从 "queue.chat" 更改为 "messaginggateway-chat-queue" 时,应用程序已成功启动。
谢谢
我是 Spring RabbitMQ 的新手。我正在尝试将我的 ChatMesssage 对象发送到 RabbitMQ,但是在配置 RabbitMQ 期间,我收到以下错误:
org.springframework.amqp.rabbit.listener.exception.FatalListenerExecutionException: Invalid listener at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1142) at java.lang.Thread.run(Unknown Source) Caused by: org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Failed to invoke target method 'handleMessage' with argument type = [class [B], value = [{[B@6bced6b0}] at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.invokeListenerMethod(MessageListenerAdapter.java:348) at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.onMessage(MessageListenerAdapter.java:253) at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:756) at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:679) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access[=13=]1(SimpleMessageListenerContainer.java:83) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.invokeListener(SimpleMessageListenerContainer.java:170) at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.invokeListener(SimpleMessageListenerContainer.java:1257) at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener
兔子配置Class:
@Bean
TopicExchange directExchange(){
return new TopicExchange(MessagingBusNamespace.CHAT_MESSAGE_TOPIC_EXCHANGE);
}
@Bean
Binding binding(final Queue queue, final Exchange exchange){
return BindingBuilder.bind(queue).to(exchange).with(MessagingBusNamespace.ROUTE_KEY).noargs();
}
@Bean
HTTPChatMessageReceiver receiver(){
return new HTTPChatMessageReceiver();
}
@Bean
MessageListenerAdapter messageListenerAdapter(){
return new MessageListenerAdapter(receiver(), "handleMessage");
}
@Bean
SimpleMessageListenerContainer simpleMessageListenerContainer(final ConnectionFactory connectionFactory,
final MessageListenerAdapter messageListenerAdapter){
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.setQueueNames(MessagingBusNamespace.CHAT_MESSAGE_QUEUE);
container.setMessageListener(messageListenerAdapter);
return container;
}
处理程序 class :
public class HTTPChatMessageReceiver {
public HTTPChatMessageReceiver() {
// TODO Auto-generated constructor stub
}
public void handleMessage(ChatMessage message) {
}
}
终于找到问题了。该问题与 MessagingListenerAdapter 无关。这与我如何定义队列名称有关。 如果我声明队列如 "queue.chat",Spring 将抛出上述异常。 当我将队列名称从 "queue.chat" 更改为 "messaginggateway-chat-queue" 时,应用程序已成功启动。
谢谢