王春明(,226007):文章介绍了中间件技术及消息中间件的概念,对SUN公司提出的JMS标准进行了分析,提出了一个基于JMS消息中间件的分布式应用方法.:中间件;分布式系统;JMS:TP393.09:A:(200341):(1962-),,,,,.:1673-2340(2006)01-0071-03MiddlewareTechnologyandItsApplicationtoDistributedSystemWANGChun-ming(SchoolofComputerScience,NantongUniversity,Nantong226007,China)Abstract:ThepaperintroducestheconceptsofmiddlewaretechnologyandmessagemiddlewareandanalyzestheJMSstandardsuggestedbySUNCompany,therebyputtingforwardadistributedapplicationmethodbasedonJMSmiddleware.Keywords:middleware;distributedsystem;JMS,.,.,,.,.6,/.,SUNJMS(JavaMessageService),JMS.1/0,,,,.,API,,1.:,API,.(MessageOrientedMiddleware,MOM),,,.,.()JournalofNantongUniversity(NaturalScience)第5卷第1期2006年3月Vol.5No.1Mar.2006#72#()2006,.2JMSJMSSUNJAVAMOM.,(/).JMSAPI,JMS,,.JMS4:JMS,JMS2.,(ConnectionFactory)(Connection).Connection,.(Destination).(Session)JMS,,Session.(MessageProducer)(MessageConsumer)Session,.JMSAPI,(PTP)-(PUB/SUB).PTP,,,,.PUB/SUB(Topic),,,,.PTP.JMS:(1)QueueConnectionFactoryJNDIAPI;(2);(3)QueueSender;(4)TextMessage;(5);(6);(7)Finally,QueueSender.JMS:(1)QueueConnectionFactoryJNDIAPI;(2);(3)QueueReceiver;(4),;(5),;(6)Finally,QueueReceiver.JMS,.,.3JMS,,,,.3,3.,Web,WebJSP,Applet;,,J2EE,WebJMSEJB,WebWeb,-,JMS,EJB;,#73#:.(PTP),WebAppletJMS,;EJBonMessageListenerJMS,onMessage,.,,EJBEJB.Applet:publicclassMessageClientextendsjava.Applete.applet{......publicBooleanmessageSend(StringjndiConnectFactory,StringjndiQueue,StringItemId,doubleItemBid){try{ContextjndiContext=newInitialContext();QueueConnectionFactoryqueueConnectionFactory=(QueueConnectionFactory)jndiContext.lookup(jndiConnectionFactory);Queuequeue=(Queue)jndiContext.lookup(jndiQueue);QueueSessionqueueSession=queueConnec-tion.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);QueueSenderqueueSender=queueSession.createSender(queue);MapMessage.message=queueSession.createMapMessage();message.setString(ItemID,itemID);message.setDouble(ItemBid,itemBid);queueSender.send(messgae);returntrue;}catch(e){returnfalse;}}}EJB:publicvoidonMessage(javax.jms.Messagemsg){StringitemID=null;doubleitemBid=-1;try{if(msginstanceofMapMessage){javax.jms.MapMessage.map=(javax.jms.MapMessage)msg;itemID=map.getString(itemID);itemBid=map.getDouble(itemBid);......}}catch(e){...}}4,.,,.J2EEEJBJMSAPI,,JMSAPI,J2EE.,,.:[1].J2EE[M].:,2003.[2][]HenryXie.J2EE[M].:,2003.[3][]MarkHapner.JavaAPI:J2EE[M].:,2002.