Try to store servlet request to rabbitMQ

81 views
Skip to first unread message

Li ZW

unread,
Aug 14, 2016, 9:52:15 AM8/14/16
to rabbitmq-users
Recently, I try to make a web application(java and spring platform) . In the server side, I want to process the servlet request in a asynchronous way.

And I want to try using Rabbit MQ to implement this. But when I am working on it, I find it's difficult to send a HttpServletRequst object to rabbitmq.

My message convert is Jackson2JsonMessageConverter.

And below is my produce code


    public void sendDataToQueue(String queueKey, Object msgObj){
       
try{
            amqpTemplate
.convertAndSend(queueKey, msgObj);
       
}  catch (Exception e) {
            e
.printStackTrace();
       
}
   
}


Does anyone have idea about it ? 

Is it  appropriate to use RabbitMQ here to process asynchronous request ? Thanku

Michael Klishin

unread,
Aug 14, 2016, 11:03:42 AM8/14/16
to rabbitm...@googlegroups.com
You haven't posted any exception stack traces but my guess is that serializing an HttpServletRequest to JSON will
fail.

Construct your own POJO (or a map) that Spring can convert to JSON and send it over, not HTTP/app server
requests.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Gabriele Santomaggio

unread,
Aug 14, 2016, 1:31:32 PM8/14/16
to rabbitmq-users
Reply all
Reply to author
Forward
0 new messages