我已经在WebsphereFree8.5中配置了embeddedJMS。这是调度员-执行器设置。
我试图在com_ibm_ws_batch_partitionNum中配置“messageSelector”属性,但是当我配置该属性时,作业没有执行。下面是我在executor中配置的代码
<jmsActivationSpec id="batchActivationSpec" maxEndpoints="5">
<properties.wasJms destinationRef="batchJobSubmissionQueue" destinationType="javax.jms.Queue" maxBatchSize="5" maxConcurrency="5" messageSelector="com_ibm_ws_batch_applicationName = 'LibertyBatchPOC' AND com_ibm_ws_batch_partitionNum = 1" remoteServerAddress="localhost:7280:BootstrapBasicMessaging">
</properties.wasJms>
</jmsActivationSpec>完整的Executor1 Server.xml如下所示,Executor2与不同的端口相同,com_ibm_ws_batch_partitionNum配置为"2“
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>wasJmsClient-2.0</feature>
<feature>batchManagement-1.0</feature>
<feature>batch-1.0</feature>
<feature>javaMail-1.5</feature>
<feature>batchManagement-1.0</feature>
<feature>jdbc-4.1</feature>
<feature>jndi-1.0</feature>
<feature>localConnector-1.0</feature>
<feature>jaxb-2.2</feature>
</featureManager>
<!-- To access this server from a remote client add a host attribute to
the following element, e.g. host="*" -->
<httpEndpoint httpPort="9082" httpsPort="9445" id="defaultHttpEndpoint"/>
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>
<!---DB2 database setup-->
<library id="DB2Lib">
<fileset dir="${shared.resource.dir}" includes="*.jar"/>
</library>
<dataSource id="testDB" jndiName="jdbc/test" transactional="false">
<jdbcDriver libraryRef="DB2Lib"/>
<properties.db2.jcc currentSchema="TestSchema" databaseName="DB2C" password="password" portNumber="5002" serverName="aa.test.com" user="TestDB"/>
</dataSource>
<!-- Database setup for DERBY -->
<!-- Database setup for DERBY Network DB -->
<!-- Batch persistence config. References a databaseStore. -->
<batchPersistence jobStoreRef="BatchDatabaseStore"/>
<!-- The database store for the batch tables. -->
<!-- Note this database store is referenced by the batchPersistence element. -->
<databaseStore createTables="true" dataSourceRef="batchDB" id="BatchDatabaseStore" schema="JBATCH" tablePrefix=""/>
<!-- Derby JDBC driver -->
<!-- Note this library is referenced by the dataSource element -->
<library id="DerbyLib">
<fileset dir="${shared.resource.dir}/derby/lib" includes="derbyclient.jar"/>
</library>
<!-- Data source for the batch tables. -->
<!-- Note this data source is referenced by databaseStore element -->
<dataSource id="batchDB" jndiName="jdbc/batch" type="javax.sql.XADataSource">
<jdbcDriver libraryRef="DerbyLib"/>
<properties.derby.client createDatabase="create" databaseName="${shared.resource.dir}/databases/BATCHDB" password="pass" portNumber="1527" serverName="localhost" user="user"/>
</dataSource>
<jdbcDriver id="derbyDriver" javax.sql.ConnectionPoolDataSource="org.apache.derby.jdbc.ClientConnectionPoolDataSource" javax.sql.XADataSource="org.apache.derby.jdbc.ClientXADataSource" libraryRef="DerbyLib"/>
<!-- Authorization and Security -->
<keyStore id="defaultKeyStore" password="Liberty"/>
<basicRegistry id="basic" realm="ibm/api">
<user name="bob" password="bobpwd"/>
<user name="jane" password="janepwd"/>
</basicRegistry>
<authorization-roles id="com.ibm.ws.batch">
<security-role name="batchAdmin">
<user name="bob"/>
</security-role>
</authorization-roles>
<batchJmsExecutor activationSpecRef="batchActivationSpec" queueRef="batchJobSubmissionQueue"/>
<!-- note that message selector need space around the equal sign -->
<jmsActivationSpec id="batchActivationSpec" maxEndpoints="5">
<properties.wasJms destinationRef="batchJobSubmissionQueue" destinationType="javax.jms.Queue" maxBatchSize="5" maxConcurrency="5" messageSelector="com_ibm_ws_batch_applicationName = 'LibertyBatchPOC' AND com_ibm_ws_batch_partitionNum=1" remoteServerAddress="localhost:7280:BootstrapBasicMessaging">
</properties.wasJms>
</jmsActivationSpec>
<jmsQueue id="batchJobSubmissionQueue" jndiName="jms/batch/jobSubmissionQueue">
<properties.wasJms deliveryMode="Persistent" queueName="batchLibertyQueue" readAhead="AsConnection" timeToLive="0"/>
</jmsQueue>
<logging maxFileSize="200" maxFiles="10" traceFileName="trace.log" traceSpecification="com.ibm.jbatch.*=all:com.ibm.ws.jbatch.*=all"/>
<applicationMonitor updateTrigger="mbean"/>
</server>调度员Server.xml
<?xml version="1.0" encoding="UTF-8"?>
<server description="BatchDispatcher">
<!-- BATCH DISPATCHER -->
<!-- Enabled features -->
<featureManager>
<feature>wasJmsClient-2.0</feature>
<feature>batchManagement-1.0</feature>
</featureManager>
<!-- JMS Configuration -->
<batchJmsDispatcher connectionFactoryRef="batchConnectionFactory"
queueRef="batchJobSubmissionQueue" />
<batchJmsEvents connectionFactoryRef="batchConnectionFactory" />
<jmsConnectionFactory id="batchConnectionFactory"
jndiName="jms/batch/connectionFactory">
<properties.wasJms remoteServerAddress="localhost:7280:BootstrapBasicMessaging" />
</jmsConnectionFactory>
<jmsQueue id="batchJobSubmissionQueue" jndiName="jms/batch/jobSubmissionQueue">
<properties.wasJms deliveryMode="Persistent"
queueName="batchLibertyQueue" readAhead="AsConnection" timeToLive="0"></properties.wasJms>
</jmsQueue>
<!-- Server HTTP port setup -->
<httpEndpoint id="defaultHttpEndpoint" httpPort="9081"
httpsPort="9444" />
<!-- Database setup for DERBY -->
<!-- Database setup for DERBY Network DB -->
<!-- Batch persistence config. References a databaseStore. -->
<batchPersistence jobStoreRef="BatchDatabaseStore" />
<!-- The database store for the batch tables. -->
<!-- Note this database store is referenced by the batchPersistence element. -->
<databaseStore id="BatchDatabaseStore" createTables="true"
dataSourceRef="batchDB" schema="JBATCH" tablePrefix="" />
<!-- Derby JDBC driver -->
<!-- Note this library is referenced by the dataSource element -->
<library id="DerbyLib">
<fileset dir="${shared.resource.dir}/derby/lib" includes="derbyclient.jar" />
</library>
<!-- Data source for the batch tables. -->
<!-- Note this data source is referenced by databaseStore element -->
<dataSource id="batchDB" jndiName="jdbc/batch" type="javax.sql.XADataSource">
<jdbcDriver libraryRef="DerbyLib" />
<properties.derby.client createDatabase="create"
databaseName="${shared.resource.dir}/databases/BATCHDB" serverName="localhost"
portNumber="1527" user="user" password="pass" />
</dataSource>
<jdbcDriver id="derbyDriver"
javax.sql.ConnectionPoolDataSource="org.apache.derby.jdbc.ClientConnectionPoolDataSource"
javax.sql.XADataSource="org.apache.derby.jdbc.ClientXADataSource"
libraryRef="DerbyLib" />
<!-- Authorization and Security -->
<keyStore id="defaultKeyStore" password="Liberty"/>
<basicRegistry id="basic" realm="ibm/api">
<user name="bob" password="bobpwd" />
<!--<user name="jane" password="janepwd" />-->
</basicRegistry>
<authorization-roles id="com.ibm.ws.batch">
<security-role name="batchAdmin">
<user name="bob" />
</security-role>
</authorization-roles>
<!-- Enable Batch tracing for troubleshooting purposes -->
<logging maxFileSize="200" maxFiles="10"
traceSpecification="com.ibm.jbatch.*=all:com.ibm.ws.jbatch.*=all"
traceFileName="trace.log" />
</server>发布于 2016-06-07 15:01:59
如果这是您仅有的两个执行者,那么作业本身就不会运行,因为没有选择器只需要得到作业。您有一个可运行分区1的执行器和一个运行分区2的执行器,但没有一个只运行实际作业的执行器。您可以调整executor 1以允许分区num值为1或NULL (未为作业本身设置),然后作业和分区1将在executor 1上运行。
注意,你得小心点。如果您将运行实际作业的服务器捆绑起来,就没有空间可以运行分区了,并且它会挂起。
发布于 2016-06-07 15:50:51
你需要两样东西。
1)您需要一个执行器,它将首先运行作业,并将分区排队供其他执行程序使用。
为此,您需要在消息选择器中没有其他属性。或者,您可以使用值为com_ibm_ws_batch_work_type的属性Job或Partition来根据类型选择和执行工作。
请注意,要在多个执行器上分发作业中的分区,需要在运行顶级作业的执行器中配置<batchJmsDispatcher>元素。
2)第二件事是运行分区所需的执行器,在该分区中,您可以使用您的消息选择器,如问题中所述(以下内容)
https://stackoverflow.com/questions/37681710
复制相似问题