Merge pull request #94 from wxlund/BATCH-1920
* BATCH-1920:
BATCH-1920 - Corrected pom and removed unused reference to JdbcTemplate
And now commit with the files that have been added for the sample.
Provided a sample to support AmqpItemReader/Writer addition to spring-batch-2.2.
Had to add back in the reference to sqlfire.
Modified core to support drop and schema-sqlf.sql but leverages derby syntax outside of connection string. Modified *.properties file to add additional property "batch.isolationlevel=ISOLATION_SERIALIZABLE because batch-sqlf.properties needs batch.isolationlevel=ISOLATION_READ_COMMITTED. Added corresponding sqlf properties and sqlf files. Modified simple-job-launcher-context.xml to support the p:isolationLevelForCreate="${batch.isolationlevel}"
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
-- Autogenerated: do not edit this file
|
||||
|
||||
DROP TABLE BATCH_STEP_EXECUTION_CONTEXT ;
|
||||
DROP TABLE BATCH_JOB_EXECUTION_CONTEXT ;
|
||||
DROP TABLE BATCH_STEP_EXECUTION ;
|
||||
DROP TABLE BATCH_JOB_EXECUTION ;
|
||||
DROP TABLE BATCH_JOB_PARAMS ;
|
||||
DROP TABLE BATCH_JOB_INSTANCE ;
|
||||
|
||||
DROP TABLE BATCH_STEP_EXECUTION_SEQ ;
|
||||
DROP TABLE BATCH_JOB_EXECUTION_SEQ ;
|
||||
DROP TABLE BATCH_JOB_SEQ ;
|
||||
@@ -0,0 +1,79 @@
|
||||
-- Autogenerated: do not edit this file
|
||||
|
||||
CREATE TABLE BATCH_JOB_INSTANCE (
|
||||
JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
|
||||
VERSION BIGINT ,
|
||||
JOB_NAME VARCHAR(100) NOT NULL,
|
||||
JOB_KEY VARCHAR(32) NOT NULL,
|
||||
constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY)
|
||||
) ;
|
||||
|
||||
CREATE TABLE BATCH_JOB_EXECUTION (
|
||||
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
|
||||
VERSION BIGINT ,
|
||||
JOB_INSTANCE_ID BIGINT NOT NULL,
|
||||
CREATE_TIME TIMESTAMP NOT NULL,
|
||||
START_TIME TIMESTAMP DEFAULT NULL ,
|
||||
END_TIME TIMESTAMP DEFAULT NULL ,
|
||||
STATUS VARCHAR(10) ,
|
||||
EXIT_CODE VARCHAR(100) ,
|
||||
EXIT_MESSAGE VARCHAR(2500) ,
|
||||
LAST_UPDATED TIMESTAMP,
|
||||
constraint JOB_INST_EXEC_FK foreign key (JOB_INSTANCE_ID)
|
||||
references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
|
||||
) ;
|
||||
|
||||
CREATE TABLE BATCH_JOB_PARAMS (
|
||||
JOB_INSTANCE_ID BIGINT NOT NULL ,
|
||||
TYPE_CD VARCHAR(6) NOT NULL ,
|
||||
KEY_NAME VARCHAR(100) NOT NULL ,
|
||||
STRING_VAL VARCHAR(250) ,
|
||||
DATE_VAL TIMESTAMP DEFAULT NULL ,
|
||||
LONG_VAL BIGINT ,
|
||||
DOUBLE_VAL DOUBLE PRECISION ,
|
||||
constraint JOB_INST_PARAMS_FK foreign key (JOB_INSTANCE_ID)
|
||||
references BATCH_JOB_INSTANCE(JOB_INSTANCE_ID)
|
||||
) ;
|
||||
|
||||
CREATE TABLE BATCH_STEP_EXECUTION (
|
||||
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
|
||||
VERSION BIGINT NOT NULL,
|
||||
STEP_NAME VARCHAR(100) NOT NULL,
|
||||
JOB_EXECUTION_ID BIGINT NOT NULL,
|
||||
START_TIME TIMESTAMP NOT NULL ,
|
||||
END_TIME TIMESTAMP DEFAULT NULL ,
|
||||
STATUS VARCHAR(10) ,
|
||||
COMMIT_COUNT BIGINT ,
|
||||
READ_COUNT BIGINT ,
|
||||
FILTER_COUNT BIGINT ,
|
||||
WRITE_COUNT BIGINT ,
|
||||
READ_SKIP_COUNT BIGINT ,
|
||||
WRITE_SKIP_COUNT BIGINT ,
|
||||
PROCESS_SKIP_COUNT BIGINT ,
|
||||
ROLLBACK_COUNT BIGINT ,
|
||||
EXIT_CODE VARCHAR(100) ,
|
||||
EXIT_MESSAGE VARCHAR(2500) ,
|
||||
LAST_UPDATED TIMESTAMP,
|
||||
constraint JOB_EXEC_STEP_FK foreign key (JOB_EXECUTION_ID)
|
||||
references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
|
||||
) ;
|
||||
|
||||
CREATE TABLE BATCH_STEP_EXECUTION_CONTEXT (
|
||||
STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
|
||||
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
|
||||
SERIALIZED_CONTEXT CLOB ,
|
||||
constraint STEP_EXEC_CTX_FK foreign key (STEP_EXECUTION_ID)
|
||||
references BATCH_STEP_EXECUTION(STEP_EXECUTION_ID)
|
||||
) ;
|
||||
|
||||
CREATE TABLE BATCH_JOB_EXECUTION_CONTEXT (
|
||||
JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY,
|
||||
SHORT_CONTEXT VARCHAR(2500) NOT NULL,
|
||||
SERIALIZED_CONTEXT CLOB ,
|
||||
constraint JOB_EXEC_CTX_FK foreign key (JOB_EXECUTION_ID)
|
||||
references BATCH_JOB_EXECUTION(JOB_EXECUTION_ID)
|
||||
) ;
|
||||
|
||||
CREATE TABLE BATCH_STEP_EXECUTION_SEQ (ID BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, DUMMY VARCHAR(1));
|
||||
CREATE TABLE BATCH_JOB_EXECUTION_SEQ (ID BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, DUMMY VARCHAR(1));
|
||||
CREATE TABLE BATCH_JOB_SEQ (ID BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, DUMMY VARCHAR(1));
|
||||
@@ -135,6 +135,11 @@
|
||||
<profile>
|
||||
<id>bootstrap</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>gemstone</id>
|
||||
<name>Release bundles for SQLFire and GemFire</name>
|
||||
<url>http://dist.gemstone.com.s3.amazonaws.com/maven/release</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>objectstyle</id>
|
||||
<name>ObjectStyle.org Repository</name>
|
||||
@@ -351,6 +356,11 @@
|
||||
</reporting>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.vmware.sqlfire</groupId>
|
||||
<artifactId>sqlfireclient</artifactId>
|
||||
<version>1.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
<environment>hsql</environment>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.vmware.sqlfire</groupId>
|
||||
<artifactId>sqlfireclient</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.batch</groupId>
|
||||
<artifactId>spring-batch-core</artifactId>
|
||||
@@ -238,6 +243,16 @@
|
||||
<artifactId>mail</artifactId>
|
||||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.amqp</groupId>
|
||||
<artifactId>spring-amqp</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.amqp</groupId>
|
||||
<artifactId>spring-rabbit</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.springframework.batch.sample.rabbitmq.amqp;
|
||||
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Simple producer class that sends {@link String} messages to the configured queue to be processed.
|
||||
* </p>
|
||||
*/
|
||||
public class AmqpMessageProducer {
|
||||
public static final int SEND_MESSAGE_COUNT = 10;
|
||||
public static final String[] BEAN_CONFIG = { "classpath:/META-INF/spring/jobs/messaging/rabbitmq-beans.xml",
|
||||
"classpath:/META-INF/spring/config-beans.xml" };
|
||||
|
||||
public static void main(String[] args) {
|
||||
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(BEAN_CONFIG);
|
||||
AmqpTemplate amqpTemplate = applicationContext.getBean("inboundAmqpTemplate", RabbitTemplate.class);
|
||||
|
||||
for (int i = 0; i < SEND_MESSAGE_COUNT; i++ ) {
|
||||
amqpTemplate.convertAndSend("foo message: " + i);
|
||||
}
|
||||
|
||||
((ConfigurableApplicationContext) applicationContext).close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.springframework.batch.sample.rabbitmq.processor;
|
||||
|
||||
import org.springframework.batch.item.ItemProcessor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Simple {@link ItemProcessor} implementation to append a "processed on" {@link Date} to a received message.
|
||||
* </p>
|
||||
*/
|
||||
public class MessageProcessor implements ItemProcessor<String, String> {
|
||||
|
||||
public String process(String message) throws Exception {
|
||||
return "Message: \"" + message + "\" processed on: " + new Date();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<beans:beans
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:batch="http://www.springframework.org/schema/batch"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
|
||||
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
||||
|
||||
<!-- Default batch context. Uses HSQL as the datasource and initalizes it. -->
|
||||
|
||||
<context:property-placeholder location="classpath:default.properties" />
|
||||
|
||||
<jdbc:initialize-database data-source="dataSource">
|
||||
<jdbc:script location="${batch.schema.script}" />
|
||||
</jdbc:initialize-database>
|
||||
|
||||
<batch:job-repository id="jobRepository" />
|
||||
|
||||
<beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
|
||||
p:driverClassName="${batch.jdbc.driver}"
|
||||
p:url="${batch.jdbc.url}"
|
||||
p:username="${batch.jdbc.user}"
|
||||
p:password="${batch.jdbc.password}"/>
|
||||
|
||||
<beans:bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
|
||||
p:dataSource-ref="dataSource"/>
|
||||
|
||||
<beans:bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher"
|
||||
p:jobRepository-ref="jobRepository"/>
|
||||
</beans:beans>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<beans:beans
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
|
||||
|
||||
<!-- Property values used in the application -->
|
||||
<context:property-placeholder location="classpath:default.amqp.properties" />
|
||||
</beans:beans>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<beans:beans
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
|
||||
|
||||
<beans:bean id="amqpItemReader" class="org.springframework.batch.item.amqp.AmqpItemReader">
|
||||
<beans:constructor-arg ref="inboundAmqpTemplate"/>
|
||||
</beans:bean>
|
||||
|
||||
<beans:bean id="amqpItemProcessor" class="org.springframework.batch.sample.rabbitmq.processor.MessageProcessor"/>
|
||||
|
||||
<beans:bean id="amqpItemWriter" class="org.springframework.batch.item.amqp.AmqpItemWriter">
|
||||
<beans:constructor-arg ref="outboundAmqpTemplate"/>
|
||||
</beans:bean>
|
||||
</beans:beans>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<beans:beans
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:batch="http://www.springframework.org/schema/batch"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
|
||||
|
||||
<beans:import resource="classpath:/META-INF/spring/config-beans.xml"/>
|
||||
<!-- <beans:import resource="classpath:/META-INF/spring/batch-beans.xml"/> -->
|
||||
<beans:import resource="classpath:/META-INF/spring/jobs/messaging/rabbitmq-beans.xml"/>
|
||||
<beans:import resource="classpath:/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml"/>
|
||||
|
||||
<batch:job id="amqp-example-job">
|
||||
<batch:step id="processQueue">
|
||||
<batch:tasklet>
|
||||
<batch:chunk reader="amqpItemReader" processor="amqpItemProcessor" writer="amqpItemWriter" commit-interval="10"/>
|
||||
</batch:tasklet>
|
||||
</batch:step>
|
||||
</batch:job>
|
||||
</beans:beans>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<beans:beans
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
|
||||
|
||||
<rabbit:connection-factory id="rabbitConnectionFactory" port="${rabbitmq.port}" host="${rabbitmq.host}"/>
|
||||
<rabbit:admin connection-factory="rabbitConnectionFactory"/>
|
||||
|
||||
<rabbit:queue name="${rabbitmq.inbound.queue}"/>
|
||||
<rabbit:queue name="${rabbitmq.outbound.queue}"/>
|
||||
|
||||
<beans:bean id="inboundAmqpTemplate" class="org.springframework.amqp.rabbit.core.RabbitTemplate"
|
||||
p:connectionFactory-ref="rabbitConnectionFactory" p:routingKey="${rabbitmq.inbound.queue}"
|
||||
p:queue="${rabbitmq.inbound.queue}"/>
|
||||
|
||||
<beans:bean id="outboundAmqpTemplate" class="org.springframework.amqp.rabbit.core.RabbitTemplate"
|
||||
p:connectionFactory-ref="rabbitConnectionFactory" p:routingKey="${rabbitmq.outbound.queue}"/>
|
||||
</beans:beans>
|
||||
@@ -14,4 +14,5 @@ batch.database.incrementer.parent=columnIncrementerParent
|
||||
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
|
||||
batch.grid.size=2
|
||||
batch.jdbc.pool.size=6
|
||||
batch.verify.cursor.position=false
|
||||
batch.verify.cursor.position=false
|
||||
batch.isolationlevel=ISOLATION_SERIALIZABLE
|
||||
|
||||
@@ -15,3 +15,4 @@ batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
|
||||
batch.grid.size=2
|
||||
batch.jdbc.pool.size=6
|
||||
batch.verify.cursor.position=true
|
||||
batch.isolationlevel=ISOLATION_SERIALIZABLE
|
||||
|
||||
@@ -18,3 +18,5 @@ batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
|
||||
batch.jdbc.pool.size=6
|
||||
batch.grid.size=6
|
||||
batch.verify.cursor.position=true
|
||||
batch.isolationlevel=ISOLATION_SERIALIZABLE
|
||||
|
||||
|
||||
@@ -15,3 +15,5 @@ batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
|
||||
batch.jdbc.pool.size=6
|
||||
batch.grid.size=50
|
||||
batch.verify.cursor.position=true
|
||||
batch.isolationlevel=ISOLATION_SERIALIZABLE
|
||||
|
||||
|
||||
@@ -15,3 +15,5 @@ batch.lob.handler.class=org.springframework.jdbc.support.lob.OracleLobHandler
|
||||
batch.grid.size=2
|
||||
batch.jdbc.pool.size=6
|
||||
batch.verify.cursor.position=true
|
||||
batch.isolationlevel=ISOLATION_SERIALIZABLE
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# Placeholders batch.*
|
||||
# for Derby:
|
||||
batch.jdbc.driver=com.vmware.sqlfire.jdbc.ClientDriver
|
||||
batch.jdbc.url=jdbc:sqlfire://localhost:1257/;update=true
|
||||
batch.jdbc.user=SAMPLES
|
||||
batch.jdbc.password=SAMPLES
|
||||
batch.jdbc.testWhileIdle=false
|
||||
batch.jdbc.validationQuery=
|
||||
batch.jdbc.verifyCursorPosition=false
|
||||
batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-derby.sql
|
||||
batch.schema.script=classpath:/org/springframework/batch/core/schema-sqlf.sql
|
||||
batch.business.schema.script=business-schema-sqlf.sql
|
||||
batch.data.source.init=true
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer
|
||||
batch.database.incrementer.parent=columnIncrementerParent
|
||||
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
|
||||
batch.grid.size=2
|
||||
batch.jdbc.pool.size=6
|
||||
batch.verify.cursor.position=false
|
||||
batch.isolationlevel=ISOLATION_READ_COMMITTED
|
||||
@@ -15,3 +15,5 @@ batch.database.incrementer.parent=columnIncrementerParent
|
||||
batch.grid.size=2
|
||||
batch.jdbc.pool.size=6
|
||||
batch.verify.cursor.position=true
|
||||
batch.isolationlevel=ISOLATION_SERIALIZABLE
|
||||
|
||||
|
||||
@@ -15,4 +15,6 @@ batch.database.incrementer.parent=columnIncrementerParent
|
||||
batch.jdbc.pool.size=6
|
||||
batch.grid.size=6
|
||||
batch.verify.cursor.position=true
|
||||
batch.isolationlevel=ISOLATION_SERIALIZABLE
|
||||
|
||||
|
||||
|
||||
100
spring-batch-samples/src/main/resources/business-schema-sqlf.sql
Normal file
100
spring-batch-samples/src/main/resources/business-schema-sqlf.sql
Normal file
@@ -0,0 +1,100 @@
|
||||
-- Autogenerated: do not edit this file
|
||||
-- You might need to remove this section the first time you run against a clean database
|
||||
DROP TABLE BATCH_STAGING_SEQ ;
|
||||
DROP TABLE TRADE_SEQ ;
|
||||
DROP TABLE CUSTOMER_SEQ ;
|
||||
DROP TABLE BATCH_STAGING ;
|
||||
DROP TABLE TRADE ;
|
||||
DROP TABLE CUSTOMER ;
|
||||
DROP TABLE PLAYERS ;
|
||||
DROP TABLE GAMES ;
|
||||
DROP TABLE PLAYER_SUMMARY ;
|
||||
DROP TABLE ERROR_LOG ;
|
||||
|
||||
-- Autogenerated: do not edit this file
|
||||
|
||||
CREATE TABLE CUSTOMER_SEQ (ID BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY (start with 5), DUMMY VARCHAR(1));
|
||||
CREATE TABLE BATCH_STAGING_SEQ (ID BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY (start with 0), DUMMY VARCHAR(1));
|
||||
CREATE TABLE TRADE_SEQ (ID BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY (start with 0), DUMMY VARCHAR(1));
|
||||
|
||||
CREATE TABLE BATCH_STAGING (
|
||||
ID BIGINT NOT NULL PRIMARY KEY,
|
||||
JOB_ID BIGINT NOT NULL,
|
||||
VALUE BLOB NOT NULL,
|
||||
PROCESSED CHAR(1) NOT NULL
|
||||
) ;
|
||||
|
||||
CREATE TABLE TRADE (
|
||||
ID BIGINT NOT NULL PRIMARY KEY,
|
||||
VERSION BIGINT ,
|
||||
ISIN VARCHAR(45) NOT NULL,
|
||||
QUANTITY BIGINT ,
|
||||
PRICE DECIMAL(8,2) ,
|
||||
CUSTOMER VARCHAR(45)
|
||||
) ;
|
||||
|
||||
CREATE TABLE CUSTOMER (
|
||||
ID BIGINT NOT NULL PRIMARY KEY,
|
||||
VERSION BIGINT ,
|
||||
NAME VARCHAR(45) ,
|
||||
CREDIT DECIMAL(10,2)
|
||||
) ;
|
||||
|
||||
|
||||
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (1, 0, 'customer1', 100000);
|
||||
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (2, 0, 'customer2', 100000);
|
||||
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (3, 0, 'customer3', 100000);
|
||||
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (4, 0, 'customer4', 100000);
|
||||
|
||||
--INSERT INTO CUSTOMER (VERSION, NAME, CREDIT) VALUES (0, 'customer1', 100000);
|
||||
--INSERT INTO CUSTOMER (VERSION, NAME, CREDIT) VALUES (0, 'customer2', 100000);
|
||||
--INSERT INTO CUSTOMER (VERSION, NAME, CREDIT) VALUES (0, 'customer3', 100000);
|
||||
--INSERT INTO CUSTOMER (VERSION, NAME, CREDIT) VALUES (0, 'customer4', 100000);
|
||||
|
||||
CREATE TABLE PLAYERS (
|
||||
PLAYER_ID CHAR(8) NOT NULL PRIMARY KEY,
|
||||
LAST_NAME VARCHAR(35) NOT NULL,
|
||||
FIRST_NAME VARCHAR(25) NOT NULL,
|
||||
POS VARCHAR(10) ,
|
||||
YEAR_OF_BIRTH BIGINT NOT NULL,
|
||||
YEAR_DRAFTED BIGINT NOT NULL
|
||||
) ;
|
||||
|
||||
CREATE TABLE GAMES (
|
||||
PLAYER_ID CHAR(8) NOT NULL,
|
||||
YEAR_NO BIGINT NOT NULL,
|
||||
TEAM CHAR(3) NOT NULL,
|
||||
WEEK BIGINT NOT NULL,
|
||||
OPPONENT CHAR(3) ,
|
||||
COMPLETES BIGINT ,
|
||||
ATTEMPTS BIGINT ,
|
||||
PASSING_YARDS BIGINT ,
|
||||
PASSING_TD BIGINT ,
|
||||
INTERCEPTIONS BIGINT ,
|
||||
RUSHES BIGINT ,
|
||||
RUSH_YARDS BIGINT ,
|
||||
RECEPTIONS BIGINT ,
|
||||
RECEPTIONS_YARDS BIGINT ,
|
||||
TOTAL_TD BIGINT
|
||||
) ;
|
||||
|
||||
CREATE TABLE PLAYER_SUMMARY (
|
||||
ID CHAR(8) NOT NULL,
|
||||
YEAR_NO BIGINT NOT NULL,
|
||||
COMPLETES BIGINT NOT NULL ,
|
||||
ATTEMPTS BIGINT NOT NULL ,
|
||||
PASSING_YARDS BIGINT NOT NULL ,
|
||||
PASSING_TD BIGINT NOT NULL ,
|
||||
INTERCEPTIONS BIGINT NOT NULL ,
|
||||
RUSHES BIGINT NOT NULL ,
|
||||
RUSH_YARDS BIGINT NOT NULL ,
|
||||
RECEPTIONS BIGINT NOT NULL ,
|
||||
RECEPTIONS_YARDS BIGINT NOT NULL ,
|
||||
TOTAL_TD BIGINT NOT NULL
|
||||
) ;
|
||||
|
||||
CREATE TABLE ERROR_LOG (
|
||||
JOB_NAME CHAR(20) ,
|
||||
STEP_NAME CHAR(20) ,
|
||||
MESSAGE VARCHAR(300) NOT NULL
|
||||
) ;
|
||||
@@ -0,0 +1,4 @@
|
||||
rabbitmq.port=5672
|
||||
rabbitmq.host=127.0.0.1
|
||||
rabbitmq.inbound.queue=test.inbound
|
||||
rabbitmq.outbound.queue=test.outbound
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<beans:beans
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:batch="http://www.springframework.org/schema/batch"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
|
||||
|
||||
<beans:import resource="classpath:/META-INF/spring/config-beans.xml"/>
|
||||
<beans:import resource="classpath:/META-INF/spring/jobs/messaging/rabbitmq-beans.xml"/>
|
||||
<beans:import resource="classpath:/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml"/>
|
||||
|
||||
<batch:job id="amqp-example-job">
|
||||
<batch:step id="processQueue">
|
||||
<batch:tasklet>
|
||||
<batch:chunk reader="amqpItemReader" processor="amqpItemProcessor" writer="amqpItemWriter" commit-interval="10"/>
|
||||
</batch:tasklet>
|
||||
</batch:step>
|
||||
</batch:job>
|
||||
</beans:beans>
|
||||
@@ -19,7 +19,8 @@
|
||||
</bean>
|
||||
|
||||
<bean id="jobRepository"
|
||||
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"
|
||||
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"
|
||||
p:isolationLevelForCreate = "${batch.isolationlevel}"
|
||||
p:dataSource-ref="dataSource" p:transactionManager-ref="transactionManager" p:lobHandler-ref="lobHandler"/>
|
||||
|
||||
<bean id="mapJobRepository"
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.core.explore.JobExplorer;
|
||||
import org.springframework.batch.test.JobLauncherTestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* Run the job to read from the "test.inbound" queue, process the messages and write them to the "test.outbound" queue:
|
||||
* mvn -q exec:java -Dexec.mainClass="org.springframework.batch.core.launch.support.CommandLineJobRunner" \
|
||||
* -Dexec.arguments="classpath*:/META-INF/spring/jobs/amqp/amqp-example-job.xml,amqp-example-job"
|
||||
*/
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/jobs/amqp-example-job.xml", "/job-runner-context.xml" })
|
||||
public class AMQPJobFunctionalTests {
|
||||
|
||||
@Autowired
|
||||
private JobLauncherTestUtils jobLauncherTestUtils;
|
||||
@Autowired
|
||||
private JobExplorer jobExplorer;
|
||||
|
||||
@Test
|
||||
public void testLaunchJob() throws Exception {
|
||||
|
||||
jobLauncherTestUtils.launchJob();
|
||||
|
||||
int count = jobExplorer.getJobInstances("amqp-example-job", 0, 1).size();
|
||||
|
||||
assertTrue(count > 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user