Cant convert incoming message from RabbitMQ queue
Message converter in my rabbitmqconfig file:
Consumer class:
And i get the following error whenever a message is consumed:
org.springframework.amqp.rabbit.support.ListenerExecutionFailedException: Listener method could not be invoked with the incoming message
No converter found from actual payload type 'byte[]' to expected payload type
Anyone able to help please?
82 Replies
⌛ This post has been reserved for your question.
Hey @Victor! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.Still open
what if you pass email notification dto as the argument
instead of message<emailnotificationdto>
thats what i was doing before and i was getting the same error
show how you were doing it
show rabbit config
i was also trying with just the message converter but same issue
interesting
can u show producer
sending to queue
also show the dto
producer config:
producer:
producer dto:
consumer dto:
dont you need to set connection factory for rabbit template
the message was being sent from the producer to the queue, i could see it in the rabbitmq manager

i did add the connection factory to the producer
so it sees it as json
ill check it later
thank you
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
hmmmmmmmmmmmm
what if you do something like this
does this work
this is the output: [B@f1175f8
[B@3ed5ab18
very interesting
can you try casting the payload to your dto
see if that works
like (EmailDTO) emailRequest.getPayload()?
yea
something like that
class [B cannot be cast to class com.vss.ms_resell_emailService.consumer.EmailNotificationDto
hmmmmmmmm
maybe thats something with the record
can you make a no args constructor
for email notification dto
and go back to dto in the parameter
wait nvm
i just tested it locally and thats not the problem
i asked someone else and they said it might have something to do with the type id but i recreated the exact same class and still getting the same error
yea give me a few min ill make the exact same copy
and check whats wrong
hmmmmmmmmm
can you delete the rabbit template bean
maybe that config is doing something wrong
i just made a minimal reproducer and its working fine so idk
do you have some link so i can see the classes
also
delete the simple message link listener factory
i dont think its necessary
keep just the message converter?
yea
the rest should be auto fconfigured
for the rest template
same error still
i can upload the project to github
ok
make it public and send link
ill just copy the exact classes
and check it at my own crazy machine
GitHub
GitHub - 1VSS/ms-resell-email: Email notification microservice for ...
Email notification microservice for the reselling API - 1VSS/ms-resell-email
gonna check now
🤙
switch to
also print the stack trace of the whole error
i mean just send it
i've tried that
oh
so its jackson problem
have you tested it locally
like made a queue with docker
i copied the setup and it works when i send to my queue with docker
or maybe theres something wrong with the producer
i tried publishing with the cloudAMQP manager and got the same error still

hmmm
ok lets ask someone else
i think i'll just redo everything, cant figure out whats going on
@dan1st
can u check
cant serialize to object from byte[]
with rabbitmq
at consumer
GitHub
GitHub - 1VSS/ms-resell-email: Email notification microservice for ...
Email notification microservice for the reselling API - 1VSS/ms-resell-email
wait did you recompile target after each change or no
yea but the consumer im just running the application off the IDE
lol
can you try sending
just a string
instead of dto
and see if that will work
i did that at first and it worked
i could receive and print the string
but when i changed to receive an object it started with the errors
its my first time using rabbitmq so its just a small project to try it out
i mean
wait
can you make a
producer in the same project where you have the consumer
just copy the class that sends
and see if that is gonna work
yea, sec
java.lang.IllegalArgumentException: SimpleMessageConverter only supports String, byte[] and Serializable payloads, received: com.vss.ms_resell_emailService.consumer.EmailNotificationDto
at org.springframework.amqp.support.converter.SimpleMessageConverter.createMessage(SimpleMessageConverter.java:143) ~[spring-amqp-3.2.6.jar:3.2.6]
at org.springframework.amqp.support.converter.AbstractMessageConverter.createMessage(AbstractMessageConverter.java:88) ~[spring-amqp-3.2.6.jar:3.2.6]
at org.springframework.amqp.support.converter.AbstractMessageConverter.toMessage(AbstractMessageConverter.java:70) ~[spring-amqp-3.2.6.jar:3.2.6]
at org.springframework.amqp.support.converter.AbstractMessageConverter.toMessage(AbstractMessageConverter.java:58) ~[spring-amqp-3.2.6.jar:3.2.6]
at org.springframework.amqp.rabbit.core.RabbitTemplate.convertMessageIfNecessary(RabbitTemplate.java:1905) ~[spring-rabbit-3.2.6.jar:3.2.6]
at org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:1201) ~[spring-rabbit-3.2.6.jar:3.2.6]
at org.springframework.amqp.rabbit.core.RabbitTemplate.convertAndSend(RabbitTemplate.java:1194) ~[spring-rabbit-3.2.6.jar:3.2.6]
at com.vss.ms_resell_emailService.controller.TestController.publish(TestController.java:25) ~[classes/:na]
now that gives us something
this is what i tested with
can you do
email notification dto extends serializable
and then check
yea try setting that in application yml
for testing purposes
spring.amqp.deserialization.trust.all
to true
Where is the byte[]?
listener reads content as bytes
but doesnt transform to dto
also I think that specific class should be trusted instead of all classes
testing purposes
Where is the listener?
github
GitHub
GitHub - 1VSS/ms-resell-email: Email notification microservice for ...
Email notification microservice for the reselling API - 1VSS/ms-resell-email
strategy pattern lol
im just using it to experiment with new stuff 😔
is that bad
anyway I don't really see any specific thing about byte[]s there? Is
EmailConsumer the listener you were talking about?
it's perfectly fine, I just saw ityeah the email consumer is the listener, whenever it receives the message it says it cant convert byte to the emailNotificationDto
heres stack trace
did you try if it works with the trust all
Do you have any
MessageConverter defined anywhere?If so, you can also set allowed patterns there as shown here: https://stackoverflow.com/a/78064593/10871900
Stack Overflow
Spring Boot RabbitMQ RabbitListener ListenerExecutionFailedException
org.springframework.amqp.rabbit.support.ListenerExecutionFailedException: Failed to convert message
at org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter.onMessage(
there is message converter yes
same setup works for me locally btw
Can you try adding
implements Serializable to EmailNotificationDto?
just for testinghe did
ah ok
i added spring.amqp.deserialization.trust.all=true to my application.properties but still says unauthorized
you got application properties or yml
on github its yml
application properties
oh
are you sure
oh its properties lmfao
I think you can add that method to the
RabbitMQConfig
if you don't want to trust all types
but for now, adding the property to the application.properties is finei mean
it works for me locally
so maybe the queue is the problem
its some external one
not local
im just gonna start it over from scratch, i think this has bothered you all too long already. I appreciate the help tho
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.