1.在使用JMS的情况下,如何能实现消息生产者随时发送消息,而消息消费者马上能接收到呢??
2.如何在接收到JMS消息的情况下,在IE浏览器得到信息提示呢?不知道如何实现这样的思路!
另外我现在的代码是这样的:
public class registerConsumer extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { try {
JMSMessage_Consumer JMSMessage_ConsumerRef = new JMSMessage_Consumer(); Context context = new InitialContext();
ConnectionFactory connectionFactoryRef = (ConnectionFactory) context
.lookup("weblogic.jms.ConnectionFactory");
Destination destinationRef = (Destination) context
.lookup("ghy_jms_Queue1"); Connection connection = connectionFactoryRef.createConnection(); connection.start();// ////////////启动JMS连接 Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE); MessageConsumer messageConsumerRef = session
.createConsumer(destinationRef); messageConsumerRef.setMessageListener(JMSMessage_ConsumerRef); Thread.sleep(20000); session.close();
connection.close(); } catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}}
就是每次必须调用这个servlet来停止20S达到接收消息的功能,有没有一种机制可以不用调用这个servlet来自动一直的接收消息呢,并且在前台IE浏览器端显示出来。