freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

jms學(xué)習(xí)介紹-資料下載頁(yè)

2025-08-04 09:45本頁(yè)面
  

【正文】 message: Hello World no. 14HelloReceQueue got message: Hello World no. 15HelloReceQueue got message: Hello World no. 16HelloReceQueue got message: Hello World no. 17HelloReceQueue got message: Hello World no. 18HelloReceQueue got message: Hello World no. 19HelloReceQueue got message: Hello World no. 20配置篇下面我們來(lái)看看是JMS是在JBoss下如何配置的,首先JMS需要一個(gè)數(shù)據(jù)庫(kù)來(lái)保存其持久化的消息,幸運(yùn)的是JBoss自帶有一個(gè)開(kāi)源的JAVA數(shù)據(jù)庫(kù)HSQL()在這里簡(jiǎn)單地介紹一下這個(gè)數(shù)據(jù)庫(kù),它支持標(biāo)準(zhǔn)的SQL語(yǔ)法和JDBC接口,是一個(gè)用純JAVA編寫的數(shù)據(jù)庫(kù),其實(shí)它只有一個(gè)jar文件而已:,在%JBOSS_HOME%/server/default/lib目錄下你能找到它。啟動(dòng)這個(gè)數(shù)據(jù)庫(kù)有三種模式:Server模式、進(jìn)程模式和內(nèi)存模式,在Server模式下,你可以用下面的命令讓它啟動(dòng)起來(lái):$cd %JBOSS_HOME%/server/default/lib$ java cp mydbdemoDB其中mydb是數(shù)據(jù)庫(kù)名,demoDB是數(shù)據(jù)庫(kù)別名,我們用JDBC連它是就用這個(gè)別名,用戶名是sa,密碼默認(rèn)是空,我們下列語(yǔ)句就能創(chuàng)建表、插入數(shù)據(jù)了create table employee (employee_id int,employee_name varchar(50),age int,hiredate date)insert into employee values(1, 39。linyufa39。, 33, 39。2007121739。)insert into employee values(2, 39。scott39。, 25, 39。2008112339。)insert into employee values(3, 39。larry39。, 35, 39。2004112339。)想進(jìn)一步了解HSQL的知識(shí),網(wǎng)上有很多學(xué)習(xí)資料,好了,回到我們討論的JMS話題,有了這個(gè)數(shù)據(jù)庫(kù),那我們就不必去找其他數(shù)據(jù)庫(kù)了,JMS默認(rèn)是用內(nèi)存模式來(lái)啟動(dòng)它的,所以我們基本上不用去關(guān)心它是如何工作的。1)在%JBOSS_HOME%/server/default/deploy/jms目錄下,depends optionalattributename=ConnectionManager:service= DataSourceBinding, name=DefaultDS/dependsDefaultDS這個(gè)名字就是JMS連接數(shù)據(jù)庫(kù)的數(shù)據(jù)源,可以讓其保持默認(rèn)值。2)文件,depends optionalattributename=ConnectionManager:service=DataSourceBinding,name=DefaultDS/dependsDefaultDS這個(gè)名字保持和前面一致即可,也可以讓其保持默認(rèn)值。3),找到下面的代碼段:mbeancode=name=:service=Topic,name=testTopicdependsoptionalattributename=DestinationManager:service=DestinationManager/dependsdependsoptionalattributename=SecurityManager:service=SecurityManager/dependsattributename=SecurityConfsecurityrolename=guestread=truewrite=true/rolename=publisherread=truewrite=truecreate=false/rolename=durpublisherread=truewrite=truecreate=true//security/attribute/mbean這是定義一個(gè)名叫testTopic的示例,如果你要定義一個(gè)新的topic,只需要復(fù)制這段代碼,改一下name屬性即可。同樣找到下面這段的代碼,這是定義一個(gè)名叫testQueue的示例,如果要定義一個(gè)新的queue,復(fù)制這段代碼,改一下名字即可。mbeancode=name=:service=Queue,name=testQueuedependsoptionalattributename=DestinationManager:service=DestinationManager/dependsdependsoptionalattributename=SecurityManager:service=SecurityManager/dependsattributename=MessageCounterHistoryDayLimit1/attributeattributename=SecurityConfsecurityrolename=guestread=truewrite=true/rolename=publisherread=truewrite=truecreate=false/rolename=noaccread=falsewrite=falsecreate=false//security/attribute/mbean4)啟動(dòng)Jboss后在控制臺(tái)看到如下輸出,即說(shuō)明JMS正常啟動(dòng)了09:50:28,390 INFO[A] Bound to JNDI name: queue/A09:50:28,406 INFO[B] Bound to JNDI name: queue/B09:50:28,406 INFO[C] Bound to JNDI name: queue/C09:50:28,406 INFO[D] Bound to JNDI name: queue/D09:50:28,421 INFO[ex] Bound to JNDI name: queue/ex09:50:28,437 INFO[testTopic] Bound to JNDI name:topic/testTopic09:50:28,484 INFO[securedTopic] Bound to JNDI name: topic/securedTopic09:50:28,484 INFO[testDurableTopic] Bound to JNDI name: topic/testDurableTopic09:50:28,500 INFO[testQueue] Bound to JNDI name:queue/testQueue5),在啟動(dòng)Jboss時(shí)必須指定–b ,否則本機(jī)之外的任何主機(jī)都無(wú)法連接JMS。,也可以在運(yùn)行命令時(shí)附帶上這個(gè)參數(shù),如下sh –b 從上面介紹可以看出,在Jboss下配置JMS是非常簡(jiǎn)單的,僅需要copy一段代碼,改個(gè)名字即可。如果在WebLogic下,你就要依次配置JMS Module, ConnectionFactory, Topic, Queue, Template,不過(guò)好在console都有向?qū)?,非常直觀,所以配置起來(lái)也不是什么難事。JMS編程其他注意事項(xiàng)創(chuàng)建一個(gè)JMS Connection、查找ConnectionFactory和Destination都是需要很大的系統(tǒng)開(kāi)銷的操作,所以我們的應(yīng)用程序應(yīng)避免頻繁地去做這些操作。一般情況下,我們可以把ConnectionFactory,Connection, Topic, Queue定義成類的成員變量,并在類的構(gòu)造函數(shù)里初始化他們,避免在每次接收和發(fā)送JMS消息時(shí)去做這些工作。但是因此也帶了一個(gè)問(wèn)題,就是說(shuō)當(dāng)Connection不可用了(比如JMS Server重啟了),我們的應(yīng)用程序就會(huì)開(kāi)始不工作了,所以我們要有一種機(jī)制去檢測(cè)我們的Connection是否有效,如果已經(jīng)斷掉,應(yīng)該試圖去重新連接,并通知系統(tǒng)管理員。JMS的Connection和JDBC的Connection類似,不再使用后應(yīng)該關(guān)閉,不管是正常退出,還是異常退出,否則別的客戶程序可能就再也取不到連接了。Session也是如此。因?yàn)镴MS工作模式是異步的,()這個(gè)方法,系統(tǒng)已經(jīng)啟動(dòng)了一個(gè)新的線程在工作,也就是說(shuō)退出了這行語(yǔ)句所在的方法之后,這個(gè)線程還在工作,它會(huì)不斷地去偵聽(tīng)有沒(méi)有新的JMS消息,直到這個(gè)Connection被關(guān)閉或不可用。
點(diǎn)擊復(fù)制文檔內(nèi)容
范文總結(jié)相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1