国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
Jboss 配置數(shù)據(jù)源和JMS主題與隊列 - myth
 Jboss 配置數(shù)據(jù)源和JMS主題與隊列
  
  

一,配置數(shù)據(jù)源
以配置MySQL數(shù)據(jù)庫為例,{JBOSS_HOME}是Jboss4.0.2的安裝目錄
1,從{JBOSS_HOME}\docs\examples\jca下找到mysql-ds.xml,如果是MS SQL Server 就是mssql-ds.xml;
  如果是oracle,就是oracle-ds.xml
2, 修改mysql-ds.xml的jndi-name,connection-url,driver-class,user-name,password元素,下面是一個例子
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: mysql-ds.xml,v 1.3.2.1 2004/12/01 11:46:00 schrouf Exp $ -->
<!--  Datasource config for MySQL using 3.0.9 available from:
http://www.mysql.com/downloads/api-jdbc-stable.html
-->
<datasources>
  <local-tx-datasource>
    <jndi-name>MySqlDS</jndi-name>
    <connection-url>jdbc:mysql://127.0.0.1:3306/scretary</connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>root</user-name>
    <password>pass</password>
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
    <!-- sql to call when connection is created
    <new-connection-sql>some arbitrary sql</new-connection-sql>
      -->
    <!-- sql to call on an existing pooled connection when it is obtained from pool
    <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
      -->

    <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
    <metadata>
       <type-mapping>mySQL</type-mapping>
    </metadata>
  </local-tx-datasource>
</datasources>
3,把修改好的文件拷貝到{JBOSS_HOME}\server\default\deploy下,重啟Jboss。
如果沒有錯誤的話,啟動過程會輸出:
10:15:40,593 INFO  [WrapperDataSourceService] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:service=DataSourceBinding,name=MySqlDS to JNDI name 'java:MySqlDS'
打開控制臺http://localhost:8080/jmx-console ,在jboss.jca下可以看到我們剛剛配置的數(shù)據(jù)源
name=MySqlDS,service=DataSourceBinding
name=MySqlDS,service=LocalTxCM
name=MySqlDS,service=ManagedConnectionFactory
name=MySqlDS,service=ManagedConnectionPool
4,通過Jndi名字“java:MySqlDS”就可以訪問數(shù)據(jù)源了

 

 private static void getDataSource() {
  Context ctx 
= null;
  
try {
   ctx 
= new InitialContext();
  }
 catch (NamingException e) {
   
// TODO Auto-generated catch block
   log.error("InitialContext錯誤:" + e.getMessage());
   
return;
  }

  
try {
   Object obj 
= ctx.lookup(dsJndiName);
   ds 
= (DataSource) obj;
  }
 catch (Exception e) {
   log.error(
"查找DataSource的Jndi名" + dsJndiName + "錯誤:"
     
+ e.getMessage());
  }

  
return;
 }


二 配置JMS Topic和Queue

以配置一個叫testTopic的JMS Topic和testQueue的Jms Queue為例
1,打開{JBOSS_HOME}\server\default\deploy\jms\jbossmq-destinations-service.xml文件
在</server>前后增加下面的一段:

 

 <mbean code="org.jboss.mq.server.jmx.Topic"
  name
="jboss.mq.destination:service=Topic,name=testTopic">
    
<depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
    
<depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
    
<attribute name="SecurityConf">
      
<security>
        
<role name="guest" read="true" write="true"/>
        
<role name="publisher" read="true" write="true" create="false"/>
        
<role name="durpublisher" read="true" write="true" create="true"/>
      
</security>
    
</attribute>
  
</mbean>


上面的意思是配置一個叫testTopic的Topic。可以根據(jù)自己的需要修改這個名字,其他的不用修改。
配置Queue跟Topic類似,加入下面這段:

  <mbean code="org.jboss.mq.server.jmx.Queue"
  name
="jboss.mq.destination:service=Queue,name=testQueue">
    
<depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
    
<depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
    
<attribute name="MessageCounterHistoryDayLimit">-1</attribute>
    
<attribute name="SecurityConf">
      
<security>
        
<role name="guest" read="true" write="true"/>
        
<role name="publisher" read="true" write="true" create="false"/>
        
<role name="noacc" read="false" write="false" create="false"/>
      
</security>
    
</attribute>
  
</mbean>


上面這段配置代碼是配置一個叫testQueue的Queue,也可根據(jù)需要修改名字。
2,重新啟動Jboss,如果沒有錯誤可以看到
10:15:39,281 INFO  [testTopic] Bound to JNDI name: topic/testTopic
10:15:39,296 INFO  [testQueue] Bound to JNDI name: queue/testQueue

通過Jndi名字“java:topic/testTopic”和“java:queue/testQueue”就可以訪問Topic和Queue對象了。

本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
JBoss配置詳解
JBOSS3.x 學習筆記
JBossAS Tuning Sliming jboss 瘦身配置
在jboss中通過JNDI得到數(shù)據(jù)源
jboss相關(guān)的ejb配置引用完全說明.包括jboss-web.xml,ejb-jar.xml等.
JBoss JNDI數(shù)據(jù)源密碼加密處理
更多類似文章 >>
生活服務
分享 收藏 導長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服