我正在尝试读取队列
上的消息的状态字符串我使用以下代码读取状态字符串,但状态字符串始终返回“”
JmsMessageDetailsBag detailsBag = new JmsMessageDetailsBag();
try {
InitialContext ctx = OpenTwinsFrontendUtilities.getInitialContext( false );
// lookup the queue object
Queue queue = (Queue) ctx.lookup( queueName );
// lookup the queue connection factory
QueueConnectionFactory connFactory = (QueueConnectionFactory) ctx.lookup( "jms/EJBJMSQueueConnectionFactory" );
// create a queue connection
QueueConnection queueConn = connFactory.createQueueConnection();
// create a queue session
QueueSession queueSession = queueConn.createQueueSession( false, Session.AUTO_ACKNOWLEDGE );
// create a queue browser
QueueBrowser queueBrowser = queueSession.createBrowser( queue );
// start the connection
queueConn.start();
// browse the messages
Enumeration<?> e = queueBrowser.getEnumeration();
// count number of messages
while ( e.hasMoreElements() ) {
javax.jms.Message message = (javax.jms.Message) e.nextElement();
JmsMessageDetails details = new JmsMessageDetails();
weblogic.jms.extensions.JMSMessageInfo info = new weblogic.jms.extensions.JMSMessageInfo( ((weblogic.jms.extensions.WLMessage) message) );
details.setMessageState( info.getStateString( info.getState() != 0 ? info.getState() : 1 ) );
details.setMessageId( message.getJMSMessageID() );
details.setTimeStamp( new OpenTwinsDateAndTimeImpl( new Date( message.getJMSTimestamp() ) ) );
details.setMessageBody( new OpenTwinsCLOBImpl( JsonJMSMessage.serializerPretty.toJson( message ) ) );
detailsBag.add( details );
}
但是info.getState()总是返回0; 是否有其他方法可以获得正确的状态