我用一个Applet实现监听JMS队列快速得到消息通知客户端(客户端是IE),但是怎么也不能监听到消息。 http://www-128.ibm.com/developerworks/cn/websphere/techjournal/0204_minocha/minocha.html可以实现监听,但是我有个问题,实现监听的过程中网络断掉,则程序不能监听,需要重新启动,怎么解决这个问题?期待交流。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //同步接收消息的点对点(PTP) if (qsession == null) { InitialContext ctx = JMSContext.getInitialContext(); System.out.println("-----------"+JMS_FACTORY) ; qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY); qcon = qconFactory.createQueueConnection(); qcon.start(); qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); queue = (Queue) ctx.lookup(queueName); System.out.println("-----------"+queueName) ; qsender=qsession.createSender(queue); qreceiver = qsession.createReceiver(queue); qreceiver.setMessageListener(this); qreceiver.receive(); qcon.start(); //add code as follow while (! listener.messageReceived ) { try { // pause for a second to share the CPU Thread.currentThread().sleep(1000); } catch (InterruptedException ie) { System.out.println( "ERROR: " + ie ); System.out.println("LinkedException: " + ie.toString()); System.exit(-1); } } } //使用监听器的订阅/发布(pub/sub) /* if (tsession == null) { InitialContext ctx = JMSContext.getContext(); tconFactory = (TopicConnectionFactory) ctx.lookup(JMS_FACTORY); tcon = tconFactory.createTopicConnection(); tsession = tcon.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); topic = (Topic) ctx.lookup(topicName); tsubscriber = tsession.createSubscriber(topic,value,true); tsubscriber.setMessageListener(this); tcon.start();//***************************************//add code as follow while (! listener.messageReceived ) { try { // pause for a second to share the CPU Thread.currentThread().sleep(1000); } catch (InterruptedException ie) { System.out.println( "ERROR: " + ie ); System.out.println("LinkedException: " + ie.toString()); System.exit(-1); } } //************************************************** } public static boolean messageReceived = false; Servlet完成下载后,如何刷新页面? Cannot call sendRedirect() after the response has been comm ssh整合老是出问题 帮忙 jsp的问题 String类型怎么转换为blob类型 大家来说说, 关于 EJB3 的问题!! 请问如何用java控制word文档? 请教一个写JSP的好工具 没有年终奖,没有双薪,so郁闷,散分 -------求网站开发设计规范----------- 能不能给个EJB数据库设计的实例给我?谢谢! 想学习Hibernate,现在市面上哪本教材比较好? 奇怪!为什么会显示成这样?
if (qsession == null) {
InitialContext ctx = JMSContext.getInitialContext();
System.out.println("-----------"+JMS_FACTORY) ;
qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);
qcon = qconFactory.createQueueConnection();
qcon.start();
qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
queue = (Queue) ctx.lookup(queueName);
System.out.println("-----------"+queueName) ;
qsender=qsession.createSender(queue);
qreceiver = qsession.createReceiver(queue);
qreceiver.setMessageListener(this);
qreceiver.receive();
qcon.start();
//add code as follow
while (! listener.messageReceived )
{
try
{
// pause for a second to share the CPU
Thread.currentThread().sleep(1000);
}
catch (InterruptedException ie)
{
System.out.println( "ERROR: " + ie );
System.out.println("LinkedException: " + ie.toString());
System.exit(-1);
}
} }
//使用监听器的订阅/发布(pub/sub)
/*
if (tsession == null) {
InitialContext ctx = JMSContext.getContext();
tconFactory = (TopicConnectionFactory) ctx.lookup(JMS_FACTORY);
tcon = tconFactory.createTopicConnection();
tsession = tcon.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
topic = (Topic) ctx.lookup(topicName);
tsubscriber = tsession.createSubscriber(topic,value,true);
tsubscriber.setMessageListener(this);
tcon.start();//***************************************
//add code as follow
while (! listener.messageReceived )
{
try
{
// pause for a second to share the CPU
Thread.currentThread().sleep(1000);
}
catch (InterruptedException ie)
{
System.out.println( "ERROR: " + ie );
System.out.println("LinkedException: " + ie.toString());
System.exit(-1);
}
}
//**************************************************
}