message bean 的onmessge代码如下
public void onMessage(Message incomingMsg){
TextMessage msgText = null;
StreamMessage msgObject = null;
String msgtime = null;
String nsr = null;
try {
if(incomingMsg instanceof TextMessage)
{
msgText = (TextMessage)incomingMsg;
String msgtype = msgText.getStringProperty("char");
String year = msgtype.substring(0,4);
_logger.debug("the str year is " + year);
String month = msgtype.substring(4,6);
_logger.debug("the str month is" + month);
String day = msgtype.substring(6,8);
_logger.debug("the str day is " + day);
GregorianCalendar curCalendar = new GregorianCalendar();
Date curDate = (Date) curCalendar.getTime();
DateConvert dateConvert = new DateConvert(curDate);
String nyear = dateConvert.getYear();
String nmonth = dateConvert.getMonth();
if(nmonth.length()==1)nmonth="0"+nmonth;
String nday = dateConvert.getDay();
if(nday.length()==1)nday="0"+nday;
_logger.debug("the year is " + nyear);
_logger.debug("the month is " + nmonth);
_logger.debug("the day is "+ nday);
if(day.equals(nday))
{
msgtime = msgText.getText();
_logger.debug("MMMMMMMMMMM MMMMMMMMMM get the message ok value is "+msgtime);
System.out.println("get the message ok value is"+msgtime);
}
else
{
_logger.debug("it is not.");
}
}
} catch (JMSException e) {
e.printStackTrace(); //To change body of catch statement use Options | File Templates.
} catch (Throwable te){
te.printStackTrace();
}
}
简单的做了一下比较,就是当传入的时间字符串和系统时间字符串相同的时候,就会执行,这也是可以的但是每次都会把topic中的所有消息都执行了
ejb-jar 的代码如下:
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<message-driven>
<ejb-name>AutoPracticeMSB</ejb-name>
<ejb-class>com.jt.msg.autopractice.AutoPracticeBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Topic</destination-type>
</message-driven-destination>
</message-driven>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>AutoPracticeMSB</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
weblogic-ejb-jar 代码如下:
<?xml version="1.0"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC
'-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN'
'http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd'>
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>AutoPracticeMSB</ejb-name>
<message-driven-descriptor>
<destination-jndi-name>autopracticetopic</destination-jndi-name>
<!--
<connection-factory-jndi-name>autopracticeConnectionFactory</connection-factory-jndi-name>
-->
</message-driven-descriptor>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
webloigc的config.xml的关于jms的配置如下:
<JMSConnectionFactory Name="autopracticeConnectionFactory"
MessagesMaximum="-1" JNDIName="autopracticeConnectionFactory" Targets="myserver"/>
<JMSFileStore Name="MyJMSFileStore" Directory="C:\bea702\jmsStore" SynchronousWritePolicy="Direct-Write"/>
<JMSServer Name="MyJMSServer" Store="MyJMSFileStore" Targets="myserver">
<JMSTopic Name="autopracticetopic" JNDIName="autopracticetopic" StoreEnabled="true"/>
</JMSServer>
这是整个bean的代码,我想解决的问题就是
1:发送到topic中的消息,如果我不手动删除是不会删除的,也就是说系统不会自动的把我发送的消息给over掉,或者说我用过的消息删除,还没有处理的消息留在topic中
2:我怎样可以用消息选择机制,自动过虑我的消息让到时间的才去执行
3:即时我的webloigc 死掉了,没有执行的消息在webloigc启动后仍然能够继续执行
希望各位前辈帮帮小弟,尽快解决一下问题
小弟在此先谢过.