Note that there are some explanatory texts on larger screens.

plurals
  1. POjersey rest web Service with Activemq middleware integration
    primarykey
    data
    text
    <p>I have a Restful service API developed with JAX-RS and jersey. I have deployed the same in TOMCAT 7. Now I would like to implement Activemq so that I would keep all request in a queue and process the request resource. How to do this and integrate with tomcat7. How to integrate ActiveMq with Tomcat7 or my rest service webapp. How to call the service. </p> <p>Important :- Inside the Rest Api, I am using FilterChaining concept for security concern and after verification of the calling party, I am simply forwarding the request to the resource. For this I have added in web.xml.</p> <p>Thanks </p> <p><strong>Here is my class :-</strong></p> <pre><code> public class LimitFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { //some authentication if (true) { // let the request through and process as usual chain.doFilter(request, response); } else { // handle limit case, e.g. return status code 429 (Too Many // Requests) // see http://tools.ietf.org/html/rfc6585#page-3 ((HttpServletResponse) response).sendError(429); } } } } </code></pre> <p><strong>Here is my sample class for activemq:-</strong></p> <pre><code>public class Qservlet extends HttpServlet { /** * */ private static final long serialVersionUID = 1L; public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String body = ""; try { // Create a ConnectionFactory ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("admin", "admin", ActiveMQConnection.DEFAULT_BROKER_URL); // Create a Connection Connection connection = connectionFactory.createConnection(); Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE); Destination destination = session.createQueue("testQ"); TextMessage message = session.createTextMessage(); message.setText( "My text message was send and received");// message.setJMSRedelivered(true); message.setJMSCorrelationID(request.getSession().getId()); connection.start(); MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(DeliveryMode.PERSISTENT); producer.send(message); message = null; MessageConsumer consumer = session.createConsumer(destination); message = (TextMessage) consumer.receive(1000); if (message != null) { body = message.getText(); } producer.close(); consumer.close(); session.close(); connection.close(); } catch (Exception e) { System.out.println(e.toString()); } } } </code></pre> <p>Now if any request is coming in Limit Filter class, I am forwarding directly to the resources after some authentication mecanisam. Thats why I am using filter concept for catching all request. </p> <p>Second class is example class when i am running ; messaging is enquing and dequeueing; I can see in console for ActiveMq. </p> <p>In the first class I am simply writing <strong>"chain.doFilter(request, response)"</strong> to forward all http request to the respective resource. Now How to do here. Where to put the HTTP request. I need to handle each request asynchronously. REST is synchronous. </p> <p>Please suggest some way. and explain your answer.</p> <p>Thanks/Regards Kumar Shorav</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload