使用 Liberty 嵌入式消息传递提供者启用多服务器分区支持

可设置批处理环境以便让服务器充当批处理分派器,并让其他服务器充当批处理执行程序。

开始之前

  1. 确定嵌入式消息传递引擎所在的位置。它可以在批处理分派服务器、批处理执行程序服务器或单独服务器上。完成此任务前,必须配置此服务器。JMS 连接工厂和激活规范在其配置中引用消息引擎服务器。
  2. 要配置消息引擎,请执行以下操作:
    1. wasJmsServer-1.0 功能部件添加至 server.xml
    2. 通过添加 messageEngine 元素定义消息引擎。定义用于批处理分派器和批处理执行程序的队列。以下示例说明 server.xml 文件中的消息引擎配置:
      <!-specify the ports for the message engine.
      The ports in this example are the default ports.
      This element is not needed when the default ports are used. -->
      <wasJmsEndpoint host="*" 
      		  wasJmsPort="7280" 
      		  wasJmsSSLPort="7290" 
      		  enabled="true"> 
      	</wasJmsEndpoint>
      <messagingEngine>
      	<!- queue for batch jms message. -->
      	<queue id="batchLibertyQueue" 
      		forceReliability="ReliablePersistent"
      		receiveAllowed="true"/>
      </messagingEngine>

关于此任务

批处理分派器接受来自外部客户机的请求,并将它们提供给批处理执行程序。批处理执行程序接收与其定义功能相匹配的请求,然后执行这些请求。如果作业配置为运行分区,那么批处理执行程序将它们提供给其他执行程序以运行。批处理执行程序通过使用 Java 消息传递服务 (JMS) 相互通信。此任务帮助您使用 Liberty 嵌入式消息传递提供者配置批处理分派服务器和批处理执行程序。

过程

  1. 配置批处理 JMS 分派器。
    1. 通过将 wasJmsClient-2.0 功能部件添加至 server.xml 文件中的功能部件管理器可启用 JMS 支持。
    2. batchJmsDispatcher 元素添加至托管批处理分派器的服务器上的 server.xml 文件;例如:
      <batchJmsDispatcher connectionFactoryRef={reference to a configured JMS connection factory}
      	queueRef={reference to a configured JMS queue} />
      注: 如果未指定 connectionFactoryRefqueueRef 属性,那么 connectionFactoryRef 的缺省值为 batchConnectionFactoryqueueRef 的缺省值为 batchJobSubmissionQueue。可将 batchJmsDispatcher 元素指定为 <batchJmsDispatcher/>。在 server.xml 文件中,您仍然必须配置 batchConnectionFactory JMS 连接工厂和 JMS batchJobSubmissionQueue 队列。
    3. 将相应 JMS 连接工厂和 JMS 队列添加至服务器配置。这不是特定于批处理配置的操作。 以下示例说明批处理 JMS 分派器配置及其 JMS 配置:
      注: remoteServerAddress 属性指向托管 Liberty 消息引擎的服务器的 host:port
      <batchJmsDispatcher connectionFactoryRef="batchConnectionFactory"
      		    queueRef="batchJobSubmissionQueue" />
      
      <jmsConnectionFactory id="batchConnectionFactory"	
      		      jndiName="jms/batch/connectionFactory">
      	 <properties.wasJms remoteServerAddress="host:7280:BootstrapBasicMessaging">
      	 </properties.wasJms>
      </jmsConnectionFactory>
      
      <jmsQueue id="batchJobSubmissionQueue"
      	  jndiName="jms/batch/jobSubmissionQueue">
      	 <properties.wasJms deliveryMode="Persistent" 
      			    queuename="batchLibertyQueue">
      	 </properties.wasJms>
      </jmsQueue>
      注: 确保引用的是 jmsConnectionFactory 元素(如示例中所示)而不是 jmsQueueConnectionFactory 元素。 使用 jmsQueueConnectionFactory 元素无效。您的配置应该包含 jmsConnectionFactory 元素和 jmsQueue 元素而不包含 jmsQueueConnectionFactory 元素。
  2. 配置批处理 JMS 执行程序以执行批处理作业。
    1. 通过将 wasJmsClient-2.0 功能部件添加至 server.xml 文件中的功能部件管理器可启用 JMS 支持。
    2. batchJmsDispatcher 元素添加至托管批处理执行程序的服务器上的 server.xml 文件。
      <batchJmsExecutor activationSpecRef={configured activation specification or batch executor}
      	queueRef={reference to the configured JMS queue} />
      注: 如果未将 batchJmsDispatcher 元素添加至 server.xml 文件,那么服务器不会分派分区以在多个服务器上运行,而是在分区本地运行。
      注: 如果未指定 connectionFactoryRefqueueRef 属性,那么 connectionFactoryRef 的缺省值为 batchConnectionFactoryqueueRef 的缺省值为 batchJobSubmissionQueue。可将 batchJmsDispatcher 元素指定为 <batchJmsDispatcher/>。您仍必须在 server.xml 文件中配置 batchConnectionFactory JMS 连接工厂和 batchJobSubmissionQueue
    3. 将相应 JMS 连接工厂和 JMS 队列添加至服务器配置。 这不是特定于批处理配置的操作。以下示例说明批处理 JMS 分派器配置及其 JMS 配置:
      注: remoteServerAddress 属性指向托管 Liberty 消息引擎的服务器的 host:port
      <batchJmsDispatcher connectionFactoryRef="batchConnectionFactory"
      		    queueRef="batchJobSubmissionQueue" />
      
      <jmsConnectionFactory id="batchConnectionFactory"	
      		      jndiName="jms/batch/connectionFactory">
      	 <properties.wasJms remoteServerAddress="host:7280:BootstrapBasicMessaging">
      	 </properties.wasJms>
      </jmsConnectionFactory>
      
      <jmsQueue id='batchJobSubmissionQueue"
      	  jndiName="jms/batch/jobSubmissionQueue">
      	 <properties.wasJms deliveryMode="Persistent" 
      			    queuename="batchLibertyQueue">
      	 </properties.wasJms>
      </jmsQueue>
    4. batchJmsExecutor 元素添加至托管批处理执行程序的服务器上的 server.xml;例如:
      <batchJmsExecutor activationSpecRef={configured activation specification or batch executor}
      	queueRef={reference to the configured JMS queue} />
      注: 如果未指定 activationSpecRefqueueRef 属性,那么 activationSpecRef 的缺省值为 batchConnectionFactoryqueueRef 的缺省值为 batchJobSubmissionQueue。可将 batchJmsExecutor 元素指定为 <batchJmsExecutor/>。在 server.xml 文件中,您仍然必须对 batchActivationSpec 配置 JMS 激活规范,并配置 batchJobSubmissionQueue 队列。
    5. 将相应 JMS 激活规范和 JMS 队列添加至服务器配置。这不是特定于批处理配置的操作。
    6. 通过在激活规范中包含 JMS 消息选择器来定义批处理执行程序服务器功能。
      • 根据系统定义的属性进行过滤:

        以下批处理分派器属性在批处理 JMS 消息上可用,批处理执行程序可使用它们来进行过滤以获取入站消息。

        • com_ibm_ws_batch_applicationName:用于获取作业请求的批处理应用程序的名称
        • com_ibm_ws_batch_moduleName:用于获取作业请求的批处理应用程序的模块名称
        • com_ibm_ws_batch_componentName:用于获取作业请求的批处理应用程序的组件名称
        • com_ibm_ws_batch_work_type:工作类型:“作业”
        注: 指定带有至少一个 com_ibm_ws_batch_applicationName 属性的消息选择器以确保执行程序仅接收它可以处理的作业。
        以下示例指示执行程序的 messageSelector 属性,以仅接受针对应用程序 SimpleBatchJob 的批处理作业。
        messageSelector="com_ibm_ws_batch_applicationName = 'SimpleBatchJob' AND com_ibm_ws_batch_work_type = 'Job'">
      • 根据用户定义的属性进行过滤:

        批处理分派器设置符合批处理分派器请求消息上的相应 JMS 消息属性的所有作业参数。消息选择器还可使用这些属性将额外过滤条件添加至消息选择器。属性名称或标识必须符合 JMS 消息属性约束。例如,属性是长度不受限制的字母和数字组成的序列,第一位必须为字母。字母是方法 Character.isJavaLetter 对其返回 true 的任意字符,并包含“_”和“$”。字母或数字是方法 Character.isJavaLetterOrDigit 对其返回 true 的任意字符。查看 JMS API 文档以了解有关 JMS 消息选择器的更多信息。

        以下示例使用 com_ibm_ws_batch_applicationName 属性和作业参数 specialCapability 来演示可行消息选择器:
        messageSelector="com_ibm_ws_batch_applicationName = 'SimpleBatchJob' AND specialCapability = 'superCapability'">
      以下示例演示批处理 JMS 执行程序配置及其 JMS 配置:
      <batchJmsExecutor activationSpecRef="batchActivationSpec"
      	  	  queueRef="batchJobSubmissionQueue"/>
      
      <jmsActivationSpec id="batchActivationSpec" >
      	<properties.wasJms destinationRef="batchJobSubmissionQueue"
      			   messageSelector="(com_ibm_ws_batch_applicationName = 'SimpleBatchJob' OR com_ibm_ws_batch_applicationName = 'BonusPayoutCDI') AND com_ibm_ws_batch_work_type='Job'"
      			   destinationType="javax.jms.Queue"
      			   remoteServerAddress="host:7280:BootstrapBasicMessaging">
      	</properties.wasJms>
      </jmsActivationSpec>
      
      <jmsQueue id="batchJobSubmissionQueue" 
      	  jndiName="jms/batch/jobSubmissionQueue">
      	<properties.wasJms deliveryMode="Persistent" 
      			      queueName="batchLibertyQueue">
      	</properties.wasJms>
      </jmsQueue>
  3. 配置批处理 JMS 执行程序以仅执行分区。
    1. 通过将 wasJmsClient-2.0 功能部件添加至 server.xml 文件中的功能部件管理器可启用 JMS 支持。
    2. batchJmsExecutor 元素添加至服务器上的 server.xml 文件,该服务器托管正运行批处理作业的批处理执行程序。
      <batchJmsExecutor activationSpecRef={configured activation specification or batch executor}
      	queueRef={reference to the configured JMS queue}
             replyConnectionFactoryRef={reference to the configured JMS connection factory} />
      注: 如果未指定 connectionFactoryRefqueueRef 属性,那么 connectionFactoryRef 的缺省值为 batchConnectionFactoryqueueRef 的缺省值为 batchJobSubmissionQueue。可将 batchJmsDispatcher 元素指定为 <batchJmsDispatcher/>。您仍必须在 server.xml 文件中配置 batchConnectionFactory JMS 连接工厂和 batchJobSubmissionQueue
    3. 将相应 JMS 连接工厂和 JMS 队列添加至服务器配置。这不是特定于批处理配置的操作。
    4. 通过在激活规范中包含 JMS 消息选择器来定义批处理执行程序服务器功能。
      • 根据系统定义的属性进行过滤:

        以下批处理分派器属性在批处理 JMS 消息上可用,批处理执行程序可使用它们来进行过滤以获取入站消息。

        • com_ibm_ws_batch_applicationName:用于获取作业请求的批处理应用程序的名称
        • com_ibm_ws_batch_moduleName:用于获取作业请求的批处理应用程序的模块名称
        • com_ibm_ws_batch_componentName:用于获取作业请求的批处理应用程序的组件名称
        • com_ibm_ws_batch_work_type:工作类型:“分区”
        • com_ibm_ws_batch_partitionNum(Type=Integer):要分派的分区的分区号
        • com_ibm_ws_batch_stepName:JSL 中定义的步骤的名称
        注: 指定带有至少一个 com_ibm_ws_batch_applicationName 属性的消息选择器以确保执行程序仅接收它可以处理的作业。
        以下示例指示执行程序的 messageSelector 属性,以仅接受针对应用程序 SimpleBatchJob 的分区。
        messageSelector="com_ibm_ws_batch_applicationName = 'SimpleBatchJob' AND com_ibm_ws_batch_work_type = 'Partition'">
        以下示例指示执行程序的 messageSelector 属性,以仅接受针对应用程序 SimpleBatchJob 的分区。
        messageSelector="com_ibm_ws_batch_applicationName = 'SimpleBatchJob' AND com_ibm_ws_batch_work_type = 'Partition' AND come_ibm_ws_batch_stepName = 'step1'">
      • 根据用户定义的属性进行过滤:

        批处理分派器设置符合批处理分派器请求消息上的相应 JMS 消息属性的所有作业参数。消息选择器还可使用这些属性将额外过滤条件添加至消息选择器。属性名称或标识必须符合 JMS 消息属性约束。例如,属性是长度不受限制的字母和数字组成的序列,第一位必须为字母。字母是方法 Character.isJavaLetter 对其返回 true 的任意字符,并包含“_”和“$”。字母或数字是方法 Character.isJavaLetterOrDigit 对其返回 true 的任意字符。查看 JMS API 文档以了解有关 JMS 消息选择器的更多信息。

        以下示例使用 com_ibm_ws_batch_applicationName 属性和作业参数 specialCapability 来演示可行消息选择器:
        messageSelector="com_ibm_ws_batch_applicationName = 'SimpleBatchJob' AND specialCapability = 'superCapability'">
      以下示例演示批处理 JMS 执行程序配置及其 JMS 配置:
      <jmsConnectionFactory id="batchConnectionFactory"	
                            jndiName="jms/batch/connectionFactory"/>
      
      <batchJmsExecutor activationSpecRef="batchActivationSpec"
      	  	  queueRef="batchJobSubmissionQueue"/>
                       replyConnectionFactoryRef="batchConnectionFactory"/>
      
      <jmsActivationSpec id="batchActivationSpec" >
      	<properties.wasJms destinationRef="batchJobSubmissionQueue"
      			   messageSelector="(com_ibm_ws_batch_applicationName = 'SimpleBatchJob' OR com_ibm_ws_batch_applicationName = 'BonusPayoutCDI') AND com_ibm_ws_batch_work_type='Partition'"
      			   destinationRef="batchJobSubmissionQueue"
                            destinationType="javax.jms.Queue"
      			   remoteServerAddress="host:7280:BootstrapBasicMessaging">
      	</properties.wasJms>
      </jmsActivationSpec>
      
      <jmsQueue id="batchJobSubmissionQueue" 
      	  jndiName="jms/batch/jobSubmissionQueue">
      	<properties.wasJms deliveryMode="Persistent" 
      			      queueName="batchLibertyQueue">
      	</properties.wasJms>
      </jmsQueue>
  4. 在服务器上安装批处理应用程序。有关更多信息,请参阅在 Liberty 中部署应用程序 要禁用多服务器分区执行:如果您想要多服务器支持但不想要多服务器分区执行,那么可在 jsl 作业 XML 文件中将作业属性 come.ibm.websphere.batch.partition.multiJVM 设置为 false。以下示例说明 JSL 作业如何禁用多服务器分区:
    <property name="com.ibm.websphere.batch.partition.multiJVM" value="false"/>
    注: 如果要在远程执行程序上运行分区,那么系统不会为该分区创建任何作业日志。

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



时间戳记图标 最近一次更新时间: Monday, 5 December 2016
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-libcore-mp&topic=twlp_batch_multipartitionsembed
文件名:twlp_batch_multipartitionsembed.html