配置 JCA 激活规范

您可以配置符合 Java EE 连接器体系结构 (JCA) 规范的激活规范。

关于此任务

您可以配置所安装资源适配器提供的激活规范的一个或多个实例。
注: 要对 Liberty 配置 JCA 支持,必须使用 WebSphere® Application Server Developer Tools for Eclipse 的服务器配置编辑器的“源代码”视图或某个其他文本编辑器来编辑 server.xml 文件。本主题假定在服务器中已配置具有唯一标识 MyAdapter 的资源适配器,请参阅有关配置资源适配器的文档以获取更多详细信息。以下步骤中提供了配置基本场景的端到端示例。
注: 不支持在 WebSphere® Development Tools (WDT) 的“设计”视图中编辑连接工厂、管理对象、激活规范和资源适配器的服务器配置的属性子元素。

过程

  1. 更新 server.xml 文件以在 featureManager 标记下添加 jca-1.6 功能部件。
    <featureManager>
    	<feature>jca-1.6</feature> 
    	<feature>jndi-1.0</feature>  <!-- Add the jndi feature to enable look up of connection factories and administered objects. -->   
    		... 
    </featureManager>
  2. 安装资源适配器。 例如,按如下所示更新 server.xml 文件:
    <resourceAdapter location="C:/adapters/MyAdapter.rar"/>
  3. 配置一个或多个激活规范。 当您配置激活规范时,必须提供 properties 子元素(即使您不想覆盖任何配置属性也是如此),以将 activationSpec 元素与特定资源适配器所提供的消息侦听器类型相关联。在以下示例中,MyAdapter 资源适配器仅提供一种类型的消息侦听器:
    <activationSpec id="app1/module1/MyMessageDrivenBean">
     <properties.MyAdapter messageFilter="ALL"/>
    </activationSpec>
  4. 如果需要,请标识可用的激活规范属性子元素名称。
    • 如果资源适配器仅提供一个消息侦听器接口,不包含任何 JMS 连接工厂,那么子元素名称为:properties.<rar_identifier>

    • 如果消息侦听器接口名称是唯一的,且不具有软件包名称,那么子元素名称为:properties.<rar_identifier>.<MessageListenerInterfaceName>

    • 如果激活规范实现名称是唯一的,且不具有软件包名称,那么子元素名称为:properties.<rar_identifier>.<ActivationSpecificationImplementationName>

    • 如果激活规范实现名称是唯一的,且不具有软件包名称,那么子元素名称为:properties.<rar_identifier>.<ActivationSpecificationImplementationName>

    • 在其他情况下,子元素名称为:properties.<rar_identifier>.<fully.qualified.MessageListenterInterfaceName>

  5. 请参阅有关部署消息驱动的 Bean 的文档,以了解有关如何将激活规范与消息驱动的 Bean 相关联的信息。

示例

使用以下示例来了解如何配置具有两种消息侦听器类型且接口类名唯一的资源适配器。

ra.xml 文件中的以下片段中,MyAdapter 资源适配器提供了具有唯一接口类名的两种消息侦听器类型:

<messagelistener>
<messagelistener-type>javax.resource.cci.MessageListener</messagelistener-type>
<activationspec>
 <activationspec-class>com.vendor.adapter.CCIActivationSpec</activationspec-class>
 <config-property>
  <config-property-name>maxSize</config-property-name>
  <config-property-type>java.lang.Long</config-property-type>
 </config-property>
 ...
</activationspec>
...
</messagelistener>

<messagelistener>
<messagelistener-type>com.vendor.adapter.MyMessageListener</messagelistener-type>
<activationspec>
 <activationspec-class>com.vendor.adapter.MyActivationSpec</activationspec-class>
 <config-property> 
  <config-property-name>messageFilter</config-property-name>
  <config-property-type>java.lang.String</config-property-type>
 </config-property>
 ...
</activationspec>
...
</messagelistener>
以下是此方案的服务器配置的示例:
<activationSpec id="app1/module1/CCIMessageDrivenBean">
 <properties.MyAdapter.MessageListener maxSize="1024"/>
</activationSpec> 

<activationSpec id="app1/module1/MyMessageDrivenBean">
 <properties.MyAdapter.MyMessageListener messageFilter="ALL"/>
</activationSpec>

使用以下示例以了解如何配置资源适配器,该资源适配器的两种消息侦听器类型具有唯一实现类名

ra.xml 文件中的以下片段中,MyAdapter 资源适配器提供了具有唯一实现类名的两种消息侦听器类型:

<messagelistener>
<messagelistener-type>javax.resource.cci.MessageListener</messagelistener-type>
<activationspec> 
 <activationspec-class>com.vendor.adapter.CCIActivationSpec</activationspec-class>
 <config-property>
  <config-property-name>maxSize</config-property-name> 
  <config-property-type>java.lang.Long</config-property-type>
 </config-property> 
...
</activationspec>
...
</messagelistener>

<messagelistener>
<messagelistener-type>com.vendor.adapter.MessageListener</messagelistener-type>
<activationspec>
 <activationspec-class>com.vendor.adapter.MyActivationSpec</activationspec-class>
 <config-property>
  <config-property-name>messageFilter</config-property-name>
  <config-property-type>java.lang.String</config-property-type>
 </config-property>
...
</activationspec>
...
</messagelistener>
以下是此方案的服务器配置的示例:
<activationSpec id="app1/module1/CCIMessageDrivenBean">
 <properties.MyAdapter.CCIActivationSpec maxSize="1024"/>
</activationSpec>

<activationSpec id="app1/module1/MyMessageDrivenBean">
 <properties.MyAdapter.MyActivationSpec messageFilter="ALL"/>
</activationSpec>

使用以下示例以了解如何配置资源适配器,该资源适配器的两种消息侦听器类型的简单接口类名或实现类名均不唯一。

ra.xml 文件的以下片段中,MyAdapter 资源适配器提供了两种消息侦听器类型,这两种消息侦听器类型的简单接口类名或实现类名均不唯一:

<messagelistener>
<messagelistener-type>javax.resource.cci.MessageListener</messagelistener-type>
<activationspec>
 <activationspec-class>com.vendor.adapter.cci.ActivationSpec</activationspec-class>
 <config-property>
  <config-property-name>maxSize</config-property-name>
  <config-property-type>java.lang.Long</config-property-type>
 </config-property> 
...
</activationspec>
...
</messagelistener>

<messagelistener>
<messagelistener-type>com.vendor.adapter.MessageListener</messagelistener-type> 
<activationspec>
 <activationspec-class>com.vendor.adapter.ActivationSpec</activationspec-class>
 <config-property>
  <config-property-name>messageFilter</config-property-name>
  <config-property-type>java.lang.String</config-property-type>
 </config-property>
...
</activationspec>
...
</messagelistener>
以下是此方案的服务器配置的示例:
<activationSpec id="app1/module1/CCIMessageDrivenBean">
 <properties.MyAdapter.javax.resource.cci.MessageListener maxSize="1024"/>
</activationSpec>

<activationSpec id="app1/module1/MyMessageDrivenBean">
 <properties.MyAdapter.com.vendor.adapter.MessageListener messageFilter="ALL"/>
</activationSpec>

可以覆盖配置元素名称的后缀。请参阅有关定制 JCA 配置元素的信息,以了解如何覆盖配置元素名称的后缀。


用于指示主题类型的图标 任务主题

文件名:twlp_jca_config_actspec.html