• hessian
  • quercus/php
  • resin 3.0
  • resin 3.1
  • resin 4.0

  • changes
  • configuration
  • examples
  • installing
  • overview
  • starting

  • guide: admin
  • admin
  • amber
  • bam
  • caching
  • clustering
  • comet
  • database
  • deployment
  • ejb 3.0
  • embedding
  • filters
  • ioc
  • jsf
  • jsp
  • logging
  • messaging
  • quercus
  • remoting
  • security
  • resources
  • servlets
  • third-party
  • troubleshooting
  • virtual host
  • watchdog
  • webapp
  • HOME
  • ABOUT
  • ARTICLES
  • WORKSPACE
  • NEWS
  • PROJECTS
  • PRODUCTS
  • STORE
resin
  • hessian
  • quercus/php
  • resin 3.0
  • resin 3.1
  • resin 4.0

  • changes
  • configuration
  • examples
  • installing
  • overview
  • starting

  • guide: admin
  • admin
  • amber
  • bam
  • caching
  • clustering
  • comet
  • database
  • deployment
  • ejb 3.0
  • embedding
  • filters
  • ioc
  • jsf
  • jsp
  • logging
  • messaging
  • quercus
  • remoting
  • security
  • resources
  • servlets
  • third-party
  • troubleshooting
  • virtual host
  • watchdog
  • webapp
  • HOME
  • ABOUT
  • ARTICLES
  • WORKSPACE
  • NEWS
  • PROJECTS
  • PRODUCTS
  • STORE

The SwiftMQ client is configured by adding a jndi-link to the web.xml or resin.conf.

Resin needs the swiftmq.jar from the SwiftMQ distribution in the classpath, either in resin/lib/swiftmq.jar or in WEB-INF/lib.

<web-app> <jndi-link> <jndi-name>java:comp/env/jms</jndi-name> <jndi-factory>com.swiftmq.jndi.InitialContextFactoryImpl</jndi-factory> <init-param java.naming.provider.url="smqp://localhost:4001/timeout=10000"/> </jndi-link>

The SwiftMQ router will need to be started as a separate process.

A sample servlet using the above SwiftMQ configuration sends a text message to the queue.

package qa; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import javax.naming.*; import javax.jms.*; public class SendServlet extends HttpServlet { private QueueConnectionFactory queueFactory; private Queue queue; public void init() throws ServletException { try { Context ic = new InitialContext(); Context jms = (Context) ic.lookup("java:comp/env/jms"); queueFactory = (QueueConnectionFactory) jms.lookup("QueueConnectionFactory"); queue = (Queue) jms.lookup("testqueue@router1"); } catch (Exception e) { throw new ServletException(e); } } public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { PrintWriter out = res.getWriter(); QueueConnection conn = null; try { conn = queueFactory.createQueueConnection(); QueueSession queueSession = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); QueueSender queueSender = queueSession.createSender(queue); TextMessage message = queueSession.createTextMessage(); message.setText("Test message"); out.println("Sending message: " + message.getText()); queueSender.send(message); } catch (Exception e) { throw new ServletException(e); } finally { try { conn.close(); } catch (Exception e) { } } } }
  • HOME |
  • CONTACT US |
  • DOCUMENTATION |
  • SALES |
  • WIKI
Copyright (c) 1998-2009 Caucho Technology, Inc. All rights reserved.
caucho® , resin® and quercus® are registered trademarks of Caucho Technology, Inc.
  • HOME |
  • CONTACT US |
  • DOCUMENTATION |
  • SALES |
  • WIKI
Copyright (c) 1998-2009 Caucho Technology, Inc. All rights reserved.
caucho® , resin® and quercus® are registered trademarks of Caucho Technology, Inc.