⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jms.xtp

📁 解压在c盘
💻 XTP
字号:
<s1 title="JMS: Java Message Service"><summarylist/><s2 title="Third-Party Products"><s3 title="SwiftMQ"><p>The <a href="http://www.swiftmq.com">SwiftMQ</a> client is configuredby adding a <a href="jndi.xtp#jndi-link">jndi-link</a> to the web.xmlor resin.conf.</p><p>Resin needs the swiftmq.jar from the SwiftMQ distribution in theclasspath, either in resin/lib/swiftmq.jar or in WEB-INF/lib.</p><example title="web.xml">&lt;web-app>  &lt;jndi-link>    &lt;jndi-name>java:comp/env/jms&lt;/jndi-name>    &lt;jndi-factory>com.swiftmq.jndi.InitialContextFactoryImpl&lt;/jndi-factory>    &lt;init-param java.naming.provider.url="smqp://localhost:4001/timeout=10000"/>  &lt;/jndi-link></example><p>The SwiftMQ router will need to be started as a separate process.</p><p>A sample servlet using the above SwiftMQ configuration sends atext message to the queue.</p><example title="SendServlet.java">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) {      }    }  }}</example></s3></s2></s1>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -