使用rabiitmq时,代码都一样就是不知道为什么一直子啊报错,接收端一直没有接收到消息,只会报错,错误如下:
2022
-
06
-
17
09
:
18
:
02.869
WARN
2576
--
-
[
ntContainer#
0
-
1
]
o
.
s
.
a
.
s
.
c
.
Jackson2JsonMessageConverter
:
Could
not
convert incoming message with content
-
type
[
application
/
x
-
java
-
serialized
-
object
]
,
'json'
keyword missing
.
2022
-
06
-
17
09
:
18
:
02.870
WARN
2576
--
-
[
ntContainer#
0
-
1
]
s
.
a
.
r
.
l
.
ConditionalRejectingErrorHandler
:
Execution of Rabbit message listener failed
.
org
.
springframework
.
amqp
.
rabbit
.
support
.
ListenerExecutionFailedException
:
Listener method could
not
be invoked with the incoming message
Endpoint handler details
:
Method
[
public
void
cn
.
com
.
sise
.
lab29_receiver
.
Receiver1
.
r1
(
cn
.
com
.
sise
.
lab29_receiver
.
entity
.
Weather
)
]
Bean
[
cn
.
com
.
sise
.
lab29_receiver
.
Receiver1@
455f
497e
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
adapter
.
MessagingMessageListenerAdapter
.
invokeHandler
(
MessagingMessageListenerAdapter
.
java
:
266
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
adapter
.
MessagingMessageListenerAdapter
.
invokeHandlerAndProcessResult
(
MessagingMessageListenerAdapter
.
java
:
208
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
adapter
.
MessagingMessageListenerAdapter
.
onMessage
(
MessagingMessageListenerAdapter
.
java
:
147
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
AbstractMessageListenerContainer
.
doInvokeListener
(
AbstractMessageListenerContainer
.
java
:
1657
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
AbstractMessageListenerContainer
.
actualInvokeListener
(
AbstractMessageListenerContainer
.
java
:
1576
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
AbstractMessageListenerContainer
.
invokeListener
(
AbstractMessageListenerContainer
.
java
:
1564
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
AbstractMessageListenerContainer
.
doExecuteListener
(
AbstractMessageListenerContainer
.
java
:
1555
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
AbstractMessageListenerContainer
.
executeListener
(
AbstractMessageListenerContainer
.
java
:
1499
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
SimpleMessageListenerContainer
.
doReceiveAndExecute
(
SimpleMessageListenerContainer
.
java
:
992
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
SimpleMessageListenerContainer
.
receiveAndExecute
(
SimpleMessageListenerContainer
.
java
:
939
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
SimpleMessageListenerContainer
.
access$
1600
(
SimpleMessageListenerContainer
.
java
:
84
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
SimpleMessageListenerContainer$AsyncMessageProcessingConsumer
.
mainLoop
(
SimpleMessageListenerContainer
.
java
:
1316
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
SimpleMessageListenerContainer$AsyncMessageProcessingConsumer
.
run
(
SimpleMessageListenerContainer
.
java
:
1222
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at java
.
lang
.
Thread
.
run
(
Thread
.
java
:
750
)
[
na
:
1.8
.
0
_322
]
Caused by
:
org
.
springframework
.
messaging
.
converter
.
MessageConversionException
:
Cannot convert from
[
[
B
]
to
[
cn
.
com
.
sise
.
lab29_receiver
.
entity
.
Weather
]
for
GenericMessage
[
payload
=
byte
[
137
]
,
headers
=
{
amqp_receivedDeliveryMode
=
PERSISTENT
,
amqp_receivedExchange
=
weather
-
exchange
,
amqp_deliveryTag
=
10
,
amqp_consumerQueue
=
weather
-
queue1
,
amqp_redelivered
=
false
,
id
=
e36339a0
-
75ff
-
887
d
-
b45a
-
8
ab645fac4fb
,
amqp_consumerTag
=
amq
.
ctag
-
q91lt5hjU8dmPHVCHF7x7w
,
amqp_lastInBatch
=
false
,
contentType
=
application
/
x
-
java
-
serialized
-
object
,
timestamp
=
1655428682869
}
]
at org
.
springframework
.
messaging
.
handler
.
annotation
.
support
.
PayloadMethodArgumentResolver
.
resolveArgument
(
PayloadMethodArgumentResolver
.
java
:
145
)
~
[
spring
-
messaging
-
5.3
.
20.
jar
:
5.3
.
20
]
at org
.
springframework
.
messaging
.
handler
.
invocation
.
HandlerMethodArgumentResolverComposite
.
resolveArgument
(
HandlerMethodArgumentResolverComposite
.
java
:
118
)
~
[
spring
-
messaging
-
5.3
.
20.
jar
:
5.3
.
20
]
at org
.
springframework
.
messaging
.
handler
.
invocation
.
InvocableHandlerMethod
.
getMethodArgumentValues
(
InvocableHandlerMethod
.
java
:
147
)
~
[
spring
-
messaging
-
5.3
.
20.
jar
:
5.3
.
20
]
at org
.
springframework
.
messaging
.
handler
.
invocation
.
InvocableHandlerMethod
.
invoke
(
InvocableHandlerMethod
.
java
:
115
)
~
[
spring
-
messaging
-
5.3
.
20.
jar
:
5.3
.
20
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
adapter
.
HandlerAdapter
.
invoke
(
HandlerAdapter
.
java
:
75
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
adapter
.
MessagingMessageListenerAdapter
.
invokeHandler
(
MessagingMessageListenerAdapter
.
java
:
262
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
.
.
.
13
common frames omitted
2022
-
06
-
17
09
:
18
:
02.871
WARN
2576
--
-
[
ntContainer#
0
-
1
]
ingErrorHandler$DefaultExceptionStrategy
:
Fatal message conversion error
;
message rejected
;
it will be dropped
or
routed to a dead letter exchange
,
if
so configured
:
(
Body
:
'[serialized object]'
MessageProperties
[
headers
=
{
}
,
contentType
=
application
/
x
-
java
-
serialized
-
object
,
contentLength
=
0
,
receivedDeliveryMode
=
PERSISTENT
,
priority
=
0
,
redelivered
=
false
,
receivedExchange
=
weather
-
exchange
,
receivedRoutingKey
=
,
deliveryTag
=
10
,
consumerTag
=
amq
.
ctag
-
q91lt5hjU8dmPHVCHF7x7w
,
consumerQueue
=
weather
-
queue1
]
)
2022
-
06
-
17
09
:
18
:
02.872
ERROR
2576
--
-
[
ntContainer#
0
-
1
]
o
.
s
.
a
.
r
.
l
.
SimpleMessageListenerContainer
:
Execution of Rabbit message listener failed
,
and
the error handler threw an exception
org
.
springframework
.
amqp
.
AmqpRejectAndDontRequeueException
:
Error Handler converted exception to fatal
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
ConditionalRejectingErrorHandler
.
handleError
(
ConditionalRejectingErrorHandler
.
java
:
146
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
AbstractMessageListenerContainer
.
invokeErrorHandler
(
AbstractMessageListenerContainer
.
java
:
1461
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
AbstractMessageListenerContainer
.
handleListenerException
(
AbstractMessageListenerContainer
.
java
:
1745
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
AbstractMessageListenerContainer
.
executeListener
(
AbstractMessageListenerContainer
.
java
:
1520
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
SimpleMessageListenerContainer
.
doReceiveAndExecute
(
SimpleMessageListenerContainer
.
java
:
992
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
SimpleMessageListenerContainer
.
receiveAndExecute
(
SimpleMessageListenerContainer
.
java
:
939
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
SimpleMessageListenerContainer
.
access$
1600
(
SimpleMessageListenerContainer
.
java
:
84
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
SimpleMessageListenerContainer$AsyncMessageProcessingConsumer
.
mainLoop
(
SimpleMessageListenerContainer
.
java
:
1316
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
SimpleMessageListenerContainer$AsyncMessageProcessingConsumer
.
run
(
SimpleMessageListenerContainer
.
java
:
1222
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at java
.
lang
.
Thread
.
run
(
Thread
.
java
:
750
)
[
na
:
1.8
.
0
_322
]
Caused by
:
org
.
springframework
.
amqp
.
rabbit
.
support
.
ListenerExecutionFailedException
:
Listener method could
not
be invoked with the incoming message
Endpoint handler details
:
Method
[
public
void
cn
.
com
.
sise
.
lab29_receiver
.
Receiver1
.
r1
(
cn
.
com
.
sise
.
lab29_receiver
.
entity
.
Weather
)
]
Bean
[
cn
.
com
.
sise
.
lab29_receiver
.
Receiver1@
455f
497e
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
adapter
.
MessagingMessageListenerAdapter
.
invokeHandler
(
MessagingMessageListenerAdapter
.
java
:
266
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
adapter
.
MessagingMessageListenerAdapter
.
invokeHandlerAndProcessResult
(
MessagingMessageListenerAdapter
.
java
:
208
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
adapter
.
MessagingMessageListenerAdapter
.
onMessage
(
MessagingMessageListenerAdapter
.
java
:
147
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
AbstractMessageListenerContainer
.
doInvokeListener
(
AbstractMessageListenerContainer
.
java
:
1657
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
AbstractMessageListenerContainer
.
actualInvokeListener
(
AbstractMessageListenerContainer
.
java
:
1576
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
AbstractMessageListenerContainer
.
invokeListener
(
AbstractMessageListenerContainer
.
java
:
1564
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
AbstractMessageListenerContainer
.
doExecuteListener
(
AbstractMessageListenerContainer
.
java
:
1555
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
AbstractMessageListenerContainer
.
executeListener
(
AbstractMessageListenerContainer
.
java
:
1499
)
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
.
.
.
6
common frames omitted
Caused by
:
org
.
springframework
.
messaging
.
converter
.
MessageConversionException
:
Cannot convert from
[
[
B
]
to
[
cn
.
com
.
sise
.
lab29_receiver
.
entity
.
Weather
]
for
GenericMessage
[
payload
=
byte
[
137
]
,
headers
=
{
amqp_receivedDeliveryMode
=
PERSISTENT
,
amqp_receivedExchange
=
weather
-
exchange
,
amqp_deliveryTag
=
10
,
amqp_consumerQueue
=
weather
-
queue1
,
amqp_redelivered
=
false
,
id
=
e36339a0
-
75ff
-
887
d
-
b45a
-
8
ab645fac4fb
,
amqp_consumerTag
=
amq
.
ctag
-
q91lt5hjU8dmPHVCHF7x7w
,
amqp_lastInBatch
=
false
,
contentType
=
application
/
x
-
java
-
serialized
-
object
,
timestamp
=
1655428682869
}
]
at org
.
springframework
.
messaging
.
handler
.
annotation
.
support
.
PayloadMethodArgumentResolver
.
resolveArgument
(
PayloadMethodArgumentResolver
.
java
:
145
)
~
[
spring
-
messaging
-
5.3
.
20.
jar
:
5.3
.
20
]
at org
.
springframework
.
messaging
.
handler
.
invocation
.
HandlerMethodArgumentResolverComposite
.
resolveArgument
(
HandlerMethodArgumentResolverComposite
.
java
:
118
)
~
[
spring
-
messaging
-
5.3
.
20.
jar
:
5.3
.
20
]
at org
.
springframework
.
messaging
.
handler
.
invocation
.
InvocableHandlerMethod
.
getMethodArgumentValues
(
InvocableHandlerMethod
.
java
:
147
)
~
[
spring
-
messaging
-
5.3
.
20.
jar
:
5.3
.
20
]
at org
.
springframework
.
messaging
.
handler
.
invocation
.
InvocableHandlerMethod
.
invoke
(
InvocableHandlerMethod
.
java
:
115
)
~
[
spring
-
messaging
-
5.3
.
20.
jar
:
5.3
.
20
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
adapter
.
HandlerAdapter
.
invoke
(
HandlerAdapter
.
java
:
75
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
at org
.
springframework
.
amqp
.
rabbit
.
listener
.
adapter
.
MessagingMessageListenerAdapter
.
invokeHandler
(
MessagingMessageListenerAdapter
.
java
:
262
)
~
[
spring
-
rabbit
-
2.4
.
5.
jar
:
2.4
.
5
]
.
.
.
13
common frames omitted
问题在于服务器启动类上的这个注解,要换成原始的注解才可以
换成或者注解就运行成功辣~
【已解决】Could not convert incoming message with content-type [application/x-java-serialized-object]Exec
解决错误:ErrorHandler$DefaultExceptionStrategy : Fatal message conversion error; message rejected; it will be dropped or routed to a dead letter exchang
现象:收到消息会打印告警消息::Could not
convert
in
com
ing
message
with
content-type
[null]
RabbitMQ已经实现了Jackson的消息转换(Jackson2Json
Message
Convert
er),由于考虑到效率,如下使用Gson实现消息转换。
如下消息的转换类的接口
Message
Convert
er,Jackson2Json
Message
Convert
er的父类AbstractJson
Message
Convert
er针对json转
添加 @RabbitListener 注解来指定某方法作为消息消费的方法,例如监听某 Queue 里面的消息
Message
Convert
涉及网络传输的应用序列化不可避免,发送端以某种规则将消息转成 byte 数组进行发送,接收端则以约定的规则进行 byte[] 数组的解析
RabbitMQ 的序列化是指
Message
的 body 属性,即我们真正需要传输的内容,RabbitMQ 抽象出一个...
public
Object
from
Message
(
Message
message
)
throws
Message
ConversionException {
Object
content = null;
Message
Properties properties =
message
.get
Message
Properti...
虽然说发现我打脸了,只要
Spring
-Amqp大于1.6就能
解决
,我在思路1中提出的第二个问题。但是咱们研究技术,不只是为了
解决
问题,还得有点自己的追求,提升自己的技术(其实是大活说出去了,不撞南墙不回头,并且已经有思路了,这个思路不落地总感觉憋屈),咱们要为
Spring
-Amqp小于1.6的
解决
这个问题。
Spring
-Amqp1.4 之前,没有@RabbitListener,所以要是想监听队列,常用的有两种方式, 一种是在 Xml 中配置 <rabbit:listener-contai
记录一下入门RabbitMQ问题
org.
spring
framework.amqp.rabbit.listener.exception.Listener
Exec
utionFailedException: Listener method could not be invoked with the in
com
ing
message
org.
spring
framework.messag
ing
...
Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no gette
【已解决】Could not convert incoming message with content-type [application/x-java-serialized-object]Exec
Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no gette
qq_45803140:
python 安装库报错 ERROR: Exception: Traceback (most recent call last)
m0_69469254:
python 安装库报错 ERROR: Exception: Traceback (most recent call last)
tiq2020: