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

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

关于此任务

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

过程

  1. 配置批处理 JMS 分派器。
    1. 通过将 wmqJmsClient-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 队列添加至服务器配置。这不是特定于批处理配置的操作。

      以下示例说明使用 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 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>
      
      <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 队列。
    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_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'">
      以下示例说明使用 IBM MQ 绑定方式的批处理 JMS 执行程序配置及其 JMS 配置。
      <batchJmsExecutor activationSpecRef="batchActivationSpec"
      		  queueRef="batchJobSubmissionQueue"/>
      
      <!-- 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>
      以下示例说明使用 IBM MQ 客户机方式的批处理 JMS 执行程序配置及其 JMS 配置。
      <batchJmsExecutor activationSpecRef="batchActivationSpec"
      		  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>
      
      <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 中部署应用程序

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



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