使用 IBM MQ 消息传递提供者启用多服务器支持

可设置批处理环境以便让一些服务器充当批处理分派器,而让其他服务器充当批处理执行程序。批处理分派器接受来自外部客户机的请求,并将它们提供给批处理执行程序。批处理执行程序接收与其定义功能相匹配的请求,然后执行这些请求。批处理分派器和批处理执行程序使用 Java 消息传递服务 (JMS) 进行通信。

关于此任务

此任务帮助您使用 IBM MQ 消息传递提供者来配置批处理分派服务器和批处理执行程序。

过程

  1. 配置批处理 JMS 分派器。
    1. 通过将 wmqJmsClient-2.0 功能部件添加至 server.xml 文件中的功能部件管理器可启用 JMS 支持。如果您要在 z/OS 上以“绑定”方式使用 MQ,请添加 zosTransaction-1.0 功能部件。
    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 队列添加至服务器配置。这不是特定于批处理配置的操作。

      以下示例说明使用 IBM MQ 绑定方式时的批处理 JMS 分派器配置及其 JMS 配置。

      <batchJmsDispatcher connectionFactoryRef="batchConnectionFactory"
      		      queueRef="batchJobSubmissionQueue" />
      
      <!-- wmq resource adapter -->
      <variable name="wmqJmsClient.rar.location"
         	value="${server.config.dir}/wmq.wlp.rar"/>
      
      <!-- nativeLibraryPath is required for BINDINGS mode -->
      <!-- the startup retry and reconnect retry properties are 
           recommended to ensure robustness of the system.-->
      <wmqJmsClient nativeLibraryPath="/mqm/jms/java/lib" 
      		startupRetryCount=999
      		startupRetryInterval="1000ms"
      		reconnectionRetryCount=10
      		reconnectionRetryInterval="5m">
      </wmqJmsClient>
      
      <authData password="pwd" user="user">
      </authData>
      
      <jmsConnectionFactory id="batchConnectionFactory"	
      		      jndiName="jms/batch/connectionFactory">
      	<properties.wmqJms transportType="BINDINGS"
      			   queueManager="WMQX">
      	</properties.wmqJms>
      </jmsConnectionFactory>
      
      <!-- baseQueueName is the queue defined on WMQ system -->
      <jmsQueue id="batchJobSubmissionQueue"
      	  jndiName="jms/batch/jobSubmissionQueue">
          <properties.wmqJms baseQueueName="BATCHQ"
      			  priority="QDEF"
      			  baseQueueManagerName="WMQX">
          </properties.wmqJms>
      </jmsQueue>

      以下示例说明在客户机方式下使用 IBM MQ 时的批处理 JMS 分派器配置及其 JMS 配置。

      <batchJmsDispatcher connectionFactoryRef="batchConnectionFactory"
      		      queueRef="batchJobSubmissionQueue" />
      
      <!-- wmq resource adapter -->
      <variable name="wmqJmsClient.rar.location"
         	value="${server.config.dir}/wmq.wlp.rar"/>
      
      <!-- the startup retry and reconnect retry properties are 
           recommended to ensure robustness of the system.-->
      <wmqJmsClient startupRetryCount=999
      		 startupRetryInterval="1000ms"
      		 reconnectionRetryCount=10
      		 reconnectionRetryInterval="5m">
      </wmqJmsClient>
      
      <authData password="pwd" user="user">
      </authData>
      
      <jmsConnectionFactory id="batchConnectionFactory"	
      		      jndiName="jms/batch/connectionFactory">
      	<properties.wmqJms 
      			   hostName="webs24.pok.stglabs.ibm.com"
      			   transportType="CLIENT"
      			   channel="WAS.JMS.SVRCONN"
      			   port="1414"
      			   queueManager="WMQX"/>>
      	</properties.wmqJms>
      </jmsConnectionFactory>
      
      <!-- baseQueueName is the queue defined on WMQ system -->
      <jmsQueue id="batchJobSubmissionQueue"
      	  jndiName="jms/batch/jobSubmissionQueue">
          <properties.wmqJms baseQueueName="BATCHQ"
      			  priority="QDEF"
      			  baseQueueManagerName="WMQX">
          </properties.wmqJms>
      </jmsQueue>
      注: 确保引用的是 jmsConnectionFactory 元素(如示例中所示)而不是 jmsQueueConnectionFactory 元素。 使用 jmsQueueConnectionFactory 元素不起作用。您的配置必须包含 jmsConnectionFactory 元素和 jmsQueue 元素而不包含 jmsQueueConnectionFactory 元素。
  2. 配置批处理 JMS 执行程序。
    1. 通过将 wmqJmsClient-2.0 功能部件添加至 server.xml 文件中的功能部件管理器可启用 JMS 支持。
    2. batchJmsExecutor 元素添加至托管批处理执行程序的服务器上的 server.xml 文件。
      <batchJmsExecutor activationSpecRef={configured activation specification or batch executor}
      	queueRef={reference to the configured JMS queue} />
      注: 如果未指定 activationSpecRefqueueRef 属性,那么 activationSpecRef 的缺省值为 batchActivationSpecqueueRef 的缺省值为 batchJobSubmissionQueue。您可以将 batchJmsExecutor 元素指定为 <batchJmsExecutor />。在 server.xml 文件中,您仍然必须对 batchActivationSpec 配置 JMS 激活规范,并配置 batchJobSubmissionQueue JMS 队列。

      [18.0.0.1 and later]如果您想要批量实施组安全性,请通过将 app-Security-2.0 功能部件添加至 server.xml 文件中的功能部件管理器,启用 Liberty 安全性功能部件。另外,还要将 batchOperationGroupRef 属性添加至 batchJmsExecutor 元素,如以下示例所示。

      <batchJmsExecutor activationSpecRef={configured activation specification or batch executor}
              queueRef={reference to the configured JMS queue} />
    3. 将相应 JMS 激活规范和 JMS 队列添加至服务器配置。这不是特定于批处理配置的操作。
    4. 可选: [18.0.0.1 and later]如果您想要批量实施组安全性,请将相应的操作组名节添加至 batchJmsExecutor 元素,如以下示例所示。
      <batchJmsExecutor activationSpecRef={configured activation specification or batch executor}
                    queueRef={reference to the configured JMS queue} >
              <operationGroup>GroupA</operationGroup>
       </batchJmsExecutor>
      注: 您必须配置安全注册表以支持上面列出的组名。
    5. 通过在激活规范中包含 JMS 消息选择器来定义批处理执行程序服务器功能。
      • 根据系统定义的属性进行过滤:

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

        • com_ibm_ws_batch_applicationName:用于获取作业请求的批处理应用程序的名称
        • com_ibm_ws_batch_moduleName:用于获取作业请求的批处理应用程序的模块名称
        • com_ibm_ws_batch_componentName:用于获取作业请求的批处理应用程序的组件名称
        注: 建议使用至少一个 com_ibm_ws_batch_applicationName 属性来指定消息选择器,以确保该执行程序仅接收它可处理的作业。
        以下示例指示执行程序的 messageSelector 属性,用于接受对应应用程序 SimpleBatchJobBonusPayout 的作业。
        messageSelector="com_ibm_ws_batch_applicationName = 'SimpleBatchJob' OR com_ibm_ws_batch_applicationName = 'BonusPayout'">
        以下示例指示执行程序的 messageSelector 属性,用于接受对应应用程序 SimpleBatchJob 的作业。
        messageSelector="com_ibm_ws_batch_applicationName = 'SimpleBatchJob'">
      • 根据用户定义的属性进行过滤:

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

        以下示例使用 com_ibm_ws_batch_applicationName 属性和作业参数 specialCapability 来演示可行消息选择器。
        messageSelector="com_ibm_ws_batch_applicationName = 'SimpleBatchJob' AND specialCapability = 'superCapability'">
      [18.0.0.1 and later]以下示例显示通过 IBM MQ 绑定方式来配置操作组及其 JMS 配置的批处理 JMS 执行程序。
      <batchJmsExecutor activationSpecRef="batchActivationSpec"
      		  queueRef="batchJobSubmissionQueue"/>
            <operationGroup>GroupA</operationGroup>
      </batchJmsExecutor>
      
      <!-- wmq resource adapter -->
      <variable name="wmqJmsClient.rar.location"
                value="${server.config.dir}/wmq.wlp.rar"/>
      
      <!-- nativeLibraryPath is required for BINDING mode -->
      <!-- the startup retry and reconnect retry properties are
           recommended to ensure robustness of the system.-->
      <wmqJmsClient nativeLibraryPath="/mqm/jms/java/lib" 
      		startupRetryCount=999
      		startupRetryInterval="1000ms"
      		reconnectionRetryCount=10
      		reconnectionRetryInterval="5m">
      </wmqJmsClient>
      
      <authData password="pwd" user="user">
      </authData>
      
      <JmsActivationSpec id="batchActivationSpec" >
          <properties.wmqJms destinationRef="batchJobSubmissionQueue" 
                destinationType="javax.jms.Queue"
                messageSelector="com_ibm_ws_batch_applicationName = 'SimpleBatchJob' OR com_ibm_ws_batch_applicationName = 'BonusPayout'"
                transportType="BINDINGS"
                queueManager="WMQX">
          </properties.wmqJms>
      </jmsActivationSpec>
      
      <!-- baseQueueName is the queue defined on WMQ system -->
      <jmsQueue id="batchJobSubmissionQueue"
      	  jndiName="jms/batch/jobSubmissionQueue">
          <properties.wmqJms baseQueueName="BATCHQ"
                priority="QDEF"
                baseQueueManagerName="WMQX">
          </properties.wmqJms>
      </jmsQueue>
      [18.0.0.1 and later]以下示例显示通过 IBM MQ 客户机方式来配置操作组及其 JMS 配置的批处理 JMS 执行程序。
      <batchJmsExecutor activationSpecRef="batchActivationSpec"
      		  queueRef="batchJobSubmissionQueue"/>
            <operationGroup>GroupA</operationGroup>
      </batchJmsExecutor>
      
      <!-- wmq resource adapter -->
      <variable name="wmqJmsClient.rar.location"
                value="${server.config.dir}/wmq.wlp.rar"/>
      
      <!-- the startup retry and reconnect retry properties are
           recommended to ensure robustness of the system.-->
      <wmqJmsClient startupRetryCount=999  
      		 startupRetryInterval="1000ms"
      		 reconnectionRetryCount=10
      		 reconnectionRetryInterval="5m">
      </wmqJmsClient>
      
      <authData password="pwd" user="user">
      </authData>
      
      <JmsActivationSpec id="batchActivationSpec" >
          <properties.wmqJms destinationRef="batchJobSubmissionQueue" 
      			   messageSelector="com_ibm_ws_batch_applicationName = SimpleBatchJob' OR com_ibm_ws_batch_applicationName = 'BonusPayout'"
      		 transportType="CLIENT"
      		 channel="WAS.JMS.SVRCONN"
      		 destinationType="javax.jms.Queue"
      		 queueManager="WMQX"
      		 hostName="webs24.pok.stglabs.ibm.com"
      		 port="1414">
          </properties.wmqJms>
      </jmsActivationSpec>
      
      <!-- baseQueueName is the queue defined on WMQ system -->
      <jmsQueue id="batchJobSubmissionQueue"
      	  jndiName="jms/batch/jobSubmissionQueue">
          <properties.wmqJms baseQueueName="BATCHQ"
         	baseQueueManagerName="WMQX">
          </properties.wmqJms>
      </jmsQueue>
  3. 在服务器上安装批处理应用程序。有关更多信息,请参阅在 Liberty 中部署应用程序 [17.0.0.3 and later]
    注: 要延迟作业消息的交付,请提交指定了作业参数 comm_ibm_ws_batch_message_deliveryDelay 的作业,此作业参数设置为延迟将消息交付至执行程序服务器的毫秒数。为便于 IBM MQ 延迟交付消息,CSQ4INSG IBM MQ 安装作业必须定义 SYSTEM.DDELAY.LOCAL.QUEUE。如果未定义该队列,那么将显示 MQRC_UNKNOWN_OBJECT_NAME 错误。

    要改变作业消息的优先级,请提交指定了作业参数 com_ibm_ws_batch_message_priority 的作业,该作业参数设置为有效 JMS 消息优先级(0 到 9)。JMS 规范将缺省消息优先级定义为“4”(0 为最低优先级,9 为最高优先级)。为使优先级设置生效,必须将 properties.wmqJms 配置中的优先级设置设置为 APP(而不是 QDEF)。值 QDEF 会导致使用队列定义的缺省优先级。队列定义本身必须将 MsgDeliverySequence 设置为 MQMDS_PRIORITY。

    重新启动失败的作业时使用的延迟和优先级与原始作业相同,除非在重新启动时将该作业参数指定为不同值。优先级将传播至多服务器分区的消息,但交付延迟不会传播。


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

文件名:twlp_batch_multiJVMmq.html