为了让 Restcomm SLEE Jdbc 资源适配器有多个数据源,您需要首先更改 restcomm-slee-ra-jdbc 和 restcomm-slee-ra- 中的 resource-adaptor-jar.xml 和 deploy-config.xml 文件jdbc-DU 项目,分别。下面是定义了两个 JdbcResourceAdaptor 的 resource-adaptor-jar.xml 的示例。每个数据源一个。
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE resource-adaptor-jar PUBLIC "-//Sun Microsystems, Inc.//DTD JAIN SLEE Resource Adaptor 1.1//EN" "http://java.sun.com/dtd/slee-resource-adaptor-jar_1_1.dtd">
<resource-adaptor-jar>
<resource-adaptor ignore-ra-type-event-type-check="True">
<resource-adaptor-name>JdbcResourceAdaptor</resource-adaptor-name>
<resource-adaptor-vendor>org.restcomm</resource-adaptor-vendor>
<resource-adaptor-version>1.0</resource-adaptor-version>
<resource-adaptor-type-ref>
<resource-adaptor-type-name>JDBCResourceAdaptorType</resource-adaptor-type-name>
<resource-adaptor-type-vendor>org.restcomm</resource-adaptor-type-vendor>
<resource-adaptor-type-version>1.0</resource-adaptor-type-version>
</resource-adaptor-type-ref>
<resource-adaptor-classes>
<resource-adaptor-class>
<resource-adaptor-class-name>
org.restcomm.slee.resource.jdbc.JdbcResourceAdaptor
</resource-adaptor-class-name>
</resource-adaptor-class>
</resource-adaptor-classes>
<config-property>
<config-property-name>DATASOURCE_JNDI_NAME</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>java:/STATS_DS</config-property-value>
</config-property>
<config-property>
<config-property-name>EXECUTOR_SERVICE_THREADS</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value>4</config-property-value>
</config-property>
<config-property>
<config-property-name>RA_SBB_INTERFACE_CONNECTION_GETTERS_ON</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>true</config-property-value>
</config-property>
</resource-adaptor>
<resource-adaptor ignore-ra-type-event-type-check="True">
<resource-adaptor-name>JdbcResourceAdaptor2</resource-adaptor-name>
<resource-adaptor-vendor>org.restcomm</resource-adaptor-vendor>
<resource-adaptor-version>1.0</resource-adaptor-version>
<resource-adaptor-type-ref>
<resource-adaptor-type-name>JDBCResourceAdaptorType</resource-adaptor-type-name>
<resource-adaptor-type-vendor>org.restcomm</resource-adaptor-type-vendor>
<resource-adaptor-type-version>1.0</resource-adaptor-type-version>
</resource-adaptor-type-ref>
<resource-adaptor-classes>
<resource-adaptor-class>
<resource-adaptor-class-name>
org.restcomm.slee.resource.jdbc.JdbcResourceAdaptor
</resource-adaptor-class-name>
</resource-adaptor-class>
</resource-adaptor-classes>
<config-property>
<config-property-name>DATASOURCE_JNDI_NAME</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>java:/AppConfigDS</config-property-value>
</config-property>
<config-property>
<config-property-name>EXECUTOR_SERVICE_THREADS</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value>4</config-property-value>
</config-property>
<config-property>
<config-property-name>RA_SBB_INTERFACE_CONNECTION_GETTERS_ON</config-property-name>
<config-property-type>java.lang.Boolean</config-property-type>
<config-property-value>true</config-property-value>
</config-property>
</resource-adaptor>
</resource-adaptor-jar>
然后需要使用实体名称更新 deploy-config.xml。在我的例子中,我创建了实体名称 JDBCRA 和 JDBCRA-Config。JDBCRA 将是应用程序统计的数据源,而 JDBCRA-Config 将是应用程序配置的数据源。
<?xml version="1.0" encoding="UTF-8"?>
<deploy-config>
<ra-entity
resource-adaptor-id="ResourceAdaptorID[name=JdbcResourceAdaptor,vendor=org.restcomm,version=1.0]"
entity-name="JDBCRA">
<properties/>
<ra-link name="JDBCRA" />
</ra-entity>
<ra-entity
resource-adaptor-id="ResourceAdaptorID[name=JdbcResourceAdaptor,vendor=org.restcomm,version=1.0]"
entity-name="JDBCRA-CONFIG">
<properties/>
<ra-link name="JDBCRA-CONFIG" />
</ra-entity>
</deploy-config>
然后更新 WildFly 应用服务器 (restcomm-slee-7.1.83.87-wildfly-10.1.0.Final) 的standalone.xml 以包含两个数据源:
<subsystem xmlns="urn:jboss:domain:datasources:4.0">
...
<datasource jndi-name="java:/STATS_DS" pool-name="STATS_DS">
<connection-url>jdbc:postgresql://localhost:5432/appstats</connection-url>
<driver>postgres</driver>
<pool>
<min-pool-size>20</min-pool-size>
<initial-pool-size>50</initial-pool-size>
<max-pool-size>150</max-pool-size>
</pool>
<security>
<user-name>user</user-name>
<password>password</password>
</security>
</datasource>
<datasource jndi-name="java:/AppConfigDS" pool-name="AppConfigDS">
<connection-url>jdbc:postgresql://localhost:5432/appconfig</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgres</driver>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
</datasource>
...
</datasources>
</subsystem>
其次,在您的 JAIN-SLEE 应用程序中定义两个 SBB,即 StatsDataSourceSBB 和 ConfigDataSourceSBB。在 JAIN-SLEE 应用程序的 sbb-jar.xml 中,按如下方式配置每个 SBB:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE sbb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD JAIN SLEE SBB 1.1//EN"
"http://java.sun.com/dtd/slee-sbb-jar_1_1.dtd">
<sbb-jar>
<sbb id="MainSbb">
<description>Example</description>
<sbb-name>MainSbb</sbb-name>
<sbb-vendor>au.com.example</sbb-vendor>
<sbb-version>1.0.0</sbb-version>
<sbb-alias>MainSbb</sbb-alias>
<sbb-ref>
<sbb-name>StatsDataSourceSBB</sbb-name>
<sbb-vendor>au.com.example</sbb-vendor>
<sbb-version>1.0.0</sbb-version>
<sbb-alias>StatsDataSourceSBB</sbb-alias>
</sbb-ref>
<sbb-ref>
<sbb-name>ConfigDataSourceSBB</sbb-name>
<sbb-vendor>au.com.example</sbb-vendor>
<sbb-version>1.0.0</sbb-version>
<sbb-alias>ConfigDataSourceSBB</sbb-alias>
</sbb-ref>
...
</sbb>
<sbb>
<description/>
<sbb-name>StatsDataSourceSBB</sbb-name>
<sbb-vendor>au.com.vasx</sbb-vendor>
<sbb-version>1.0.0</sbb-version>
<sbb-classes>
<sbb-abstract-class>
<sbb-abstract-class-name>au.com.example.app.sbb.statsdata.StatsDataSourceSBB</sbb-abstract-class-name>
</sbb-abstract-class>
<sbb-local-interface>
<sbb-local-interface-name>au.com.example.app.sbb.statsdata.StatsDataSourceSbbLocalObject</sbb-local-interface-name>
</sbb-local-interface>
</sbb-classes>
<event event-direction="Receive" initial-event="False">
<event-name>SimpleJdbcTaskResultEvent</event-name>
<event-type-ref>
<event-type-name>SimpleJdbcTaskResultEvent</event-type-name>
<event-type-vendor>org.restcomm</event-type-vendor>
<event-type-version>1.0</event-type-version>
</event-type-ref>
</event>
<event event-direction="Receive" initial-event="False">
<event-name>JdbcTaskExecutionThrowableEvent</event-name>
<event-type-ref>
<event-type-name>JdbcTaskExecutionThrowableEvent</event-type-name>
<event-type-vendor>org.restcomm</event-type-vendor>
<event-type-version>1.0</event-type-version>
</event-type-ref>
</event>
<resource-adaptor-type-binding>
<resource-adaptor-type-ref>
<resource-adaptor-type-name>JDBCResourceAdaptorType</resource-adaptor-type-name>
<resource-adaptor-type-vendor>org.restcomm</resource-adaptor-type-vendor>
<resource-adaptor-type-version>1.0</resource-adaptor-type-version>
</resource-adaptor-type-ref>
<activity-context-interface-factory-name>slee/ra/jdbc/1.0/acifactory</activity-context-interface-factory-name>
<resource-adaptor-entity-binding>
<resource-adaptor-object-name>slee/ra/jdbc/1.0/sbbinterface</resource-adaptor-object-name>
<resource-adaptor-entity-link>JDBCRA</resource-adaptor-entity-link>
</resource-adaptor-entity-binding>
</resource-adaptor-type-binding>
</sbb>
<sbb>
<description/>
<sbb-name>ConfigDataSourceSBB</sbb-name>
<sbb-vendor>au.com.vasx</sbb-vendor>
<sbb-version>1.0.0</sbb-version>
<sbb-classes>
<sbb-abstract-class>
<sbb-abstract-class-name>au.com.example.app.sbb.config.ConfigDataSourceSBB</sbb-abstract-class-name>
</sbb-abstract-class>
<sbb-local-interface>
<sbb-local-interface-name>au.com.example.app.sbb.config.ConfigDataSourceSbbLocalObject</sbb-local-interface-name>
</sbb-local-interface>
</sbb-classes>
<event event-direction="Receive" initial-event="False">
<event-name>SimpleJdbcTaskResultEvent</event-name>
<event-type-ref>
<event-type-name>SimpleJdbcTaskResultEvent</event-type-name>
<event-type-vendor>org.restcomm</event-type-vendor>
<event-type-version>1.0</event-type-version>
</event-type-ref>
</event>
<event event-direction="Receive" initial-event="False">
<event-name>JdbcTaskExecutionThrowableEvent</event-name>
<event-type-ref>
<event-type-name>JdbcTaskExecutionThrowableEvent</event-type-name>
<event-type-vendor>org.restcomm</event-type-vendor>
<event-type-version>1.0</event-type-version>
</event-type-ref>
</event>
<resource-adaptor-type-binding>
<resource-adaptor-type-ref>
<resource-adaptor-type-name>JDBCResourceAdaptorType</resource-adaptor-type-name>
<resource-adaptor-type-vendor>org.restcomm</resource-adaptor-type-vendor>
<resource-adaptor-type-version>1.0</resource-adaptor-type-version>
</resource-adaptor-type-ref>
<activity-context-interface-factory-name>slee/ra/jdbc/1.0/acifactory</activity-context-interface-factory-name>
<resource-adaptor-entity-binding>
<resource-adaptor-object-name>slee/ra/jdbc/1.0/sbbinterface</resource-adaptor-object-name>
<resource-adaptor-entity-link>JDBCRA-CONFIG</resource-adaptor-entity-link>
</resource-adaptor-entity-binding>
</resource-adaptor-type-binding>
</sbb>
</sbb-jar>
这应该允许您为 Restcomm JAIN-SLEE JDBC RA 定义多个数据源。
希望这可以帮助。