diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlf.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlf.sql new file mode 100644 index 000000000..68ffb0214 --- /dev/null +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-drop-sqlf.sql @@ -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 ; diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlf.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlf.sql new file mode 100644 index 000000000..f52f984fe --- /dev/null +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlf.sql @@ -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)); diff --git a/spring-batch-parent/pom.xml b/spring-batch-parent/pom.xml index d293878fb..4a6d0960c 100644 --- a/spring-batch-parent/pom.xml +++ b/spring-batch-parent/pom.xml @@ -135,6 +135,11 @@ bootstrap + + gemstone + Release bundles for SQLFire and GemFire + http://dist.gemstone.com.s3.amazonaws.com/maven/release + objectstyle ObjectStyle.org Repository @@ -351,6 +356,11 @@ + + com.vmware.sqlfire + sqlfireclient + 1.0.3 + org.aspectj aspectjrt diff --git a/spring-batch-samples/pom.xml b/spring-batch-samples/pom.xml index c44444cb9..d98df5530 100644 --- a/spring-batch-samples/pom.xml +++ b/spring-batch-samples/pom.xml @@ -17,6 +17,11 @@ hsql + + com.vmware.sqlfire + sqlfireclient + true + org.springframework.batch spring-batch-core @@ -238,6 +243,16 @@ mail 1.4.1 + + org.springframework.amqp + spring-amqp + true + + + org.springframework.amqp + spring-rabbit + true + diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/amqp/AmqpMessageProducer.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/amqp/AmqpMessageProducer.java new file mode 100644 index 000000000..72e053f49 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/amqp/AmqpMessageProducer.java @@ -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; + +/** + *

+ * Simple producer class that sends {@link String} messages to the configured queue to be processed. + *

+ */ +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(); + } +} diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/processor/MessageProcessor.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/processor/MessageProcessor.java new file mode 100644 index 000000000..e527a2973 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/rabbitmq/processor/MessageProcessor.java @@ -0,0 +1,17 @@ +package org.springframework.batch.sample.rabbitmq.processor; + +import org.springframework.batch.item.ItemProcessor; + +import java.util.Date; + +/** + *

+ * Simple {@link ItemProcessor} implementation to append a "processed on" {@link Date} to a received message. + *

+ */ +public class MessageProcessor implements ItemProcessor { + + public String process(String message) throws Exception { + return "Message: \"" + message + "\" processed on: " + new Date(); + } +} diff --git a/spring-batch-samples/src/main/resources/META-INF/spring/batch-beans.xml b/spring-batch-samples/src/main/resources/META-INF/spring/batch-beans.xml new file mode 100644 index 000000000..dedbab573 --- /dev/null +++ b/spring-batch-samples/src/main/resources/META-INF/spring/batch-beans.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/spring-batch-samples/src/main/resources/META-INF/spring/config-beans.xml b/spring-batch-samples/src/main/resources/META-INF/spring/config-beans.xml new file mode 100644 index 000000000..f5dc575de --- /dev/null +++ b/spring-batch-samples/src/main/resources/META-INF/spring/config-beans.xml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml b/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml new file mode 100644 index 000000000..8d77e3866 --- /dev/null +++ b/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job-beans.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + diff --git a/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job.xml b/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job.xml new file mode 100644 index 000000000..2e74b98eb --- /dev/null +++ b/spring-batch-samples/src/main/resources/META-INF/spring/jobs/amqp/amqp-example-job.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + diff --git a/spring-batch-samples/src/main/resources/META-INF/spring/jobs/messaging/rabbitmq-beans.xml b/spring-batch-samples/src/main/resources/META-INF/spring/jobs/messaging/rabbitmq-beans.xml new file mode 100644 index 000000000..4bca5f143 --- /dev/null +++ b/spring-batch-samples/src/main/resources/META-INF/spring/jobs/messaging/rabbitmq-beans.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + diff --git a/spring-batch-samples/src/main/resources/batch-derby.properties b/spring-batch-samples/src/main/resources/batch-derby.properties index 97302789d..385ec9ca5 100644 --- a/spring-batch-samples/src/main/resources/batch-derby.properties +++ b/spring-batch-samples/src/main/resources/batch-derby.properties @@ -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 \ No newline at end of file +batch.verify.cursor.position=false +batch.isolationlevel=ISOLATION_SERIALIZABLE diff --git a/spring-batch-samples/src/main/resources/batch-h2.properties b/spring-batch-samples/src/main/resources/batch-h2.properties index f8cedeb70..925428ced 100644 --- a/spring-batch-samples/src/main/resources/batch-h2.properties +++ b/spring-batch-samples/src/main/resources/batch-h2.properties @@ -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 diff --git a/spring-batch-samples/src/main/resources/batch-hsql.properties b/spring-batch-samples/src/main/resources/batch-hsql.properties index b4ca5b5b3..41423fa1d 100644 --- a/spring-batch-samples/src/main/resources/batch-hsql.properties +++ b/spring-batch-samples/src/main/resources/batch-hsql.properties @@ -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 + diff --git a/spring-batch-samples/src/main/resources/batch-mysql.properties b/spring-batch-samples/src/main/resources/batch-mysql.properties index a39515564..947c24b7b 100644 --- a/spring-batch-samples/src/main/resources/batch-mysql.properties +++ b/spring-batch-samples/src/main/resources/batch-mysql.properties @@ -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 + diff --git a/spring-batch-samples/src/main/resources/batch-oracle.properties b/spring-batch-samples/src/main/resources/batch-oracle.properties index 811284365..22c75d505 100644 --- a/spring-batch-samples/src/main/resources/batch-oracle.properties +++ b/spring-batch-samples/src/main/resources/batch-oracle.properties @@ -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 + diff --git a/spring-batch-samples/src/main/resources/batch-sqlf.properties b/spring-batch-samples/src/main/resources/batch-sqlf.properties new file mode 100644 index 000000000..f47ecf9d1 --- /dev/null +++ b/spring-batch-samples/src/main/resources/batch-sqlf.properties @@ -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 \ No newline at end of file diff --git a/spring-batch-samples/src/main/resources/batch-sqlserver.properties b/spring-batch-samples/src/main/resources/batch-sqlserver.properties index a79606c7f..f6307adf9 100644 --- a/spring-batch-samples/src/main/resources/batch-sqlserver.properties +++ b/spring-batch-samples/src/main/resources/batch-sqlserver.properties @@ -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 + diff --git a/spring-batch-samples/src/main/resources/batch-sybase.properties b/spring-batch-samples/src/main/resources/batch-sybase.properties index 922ba570c..706bc4c62 100644 --- a/spring-batch-samples/src/main/resources/batch-sybase.properties +++ b/spring-batch-samples/src/main/resources/batch-sybase.properties @@ -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 + diff --git a/spring-batch-samples/src/main/resources/business-schema-sqlf.sql b/spring-batch-samples/src/main/resources/business-schema-sqlf.sql new file mode 100644 index 000000000..027892559 --- /dev/null +++ b/spring-batch-samples/src/main/resources/business-schema-sqlf.sql @@ -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 +) ; diff --git a/spring-batch-samples/src/main/resources/default.amqp.properties b/spring-batch-samples/src/main/resources/default.amqp.properties new file mode 100644 index 000000000..9394facee --- /dev/null +++ b/spring-batch-samples/src/main/resources/default.amqp.properties @@ -0,0 +1,4 @@ +rabbitmq.port=5672 +rabbitmq.host=127.0.0.1 +rabbitmq.inbound.queue=test.inbound +rabbitmq.outbound.queue=test.outbound diff --git a/spring-batch-samples/src/main/resources/jobs/amqp-example-job.xml b/spring-batch-samples/src/main/resources/jobs/amqp-example-job.xml new file mode 100644 index 000000000..b8dba281c --- /dev/null +++ b/spring-batch-samples/src/main/resources/jobs/amqp-example-job.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + diff --git a/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml b/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml index 6f0fd01f9..147ae9dd2 100644 --- a/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml +++ b/spring-batch-samples/src/main/resources/simple-job-launcher-context.xml @@ -19,7 +19,8 @@ 0); + + } + +}