RESOLVED - issue BATCH-1239: Add email-sending item writer

This commit is contained in:
dsyer
2010-01-12 17:05:56 +00:00
parent db14e83fdc
commit 953fb3a5b4
18 changed files with 1065 additions and 9 deletions

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
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-2.0.xsd">
<job id="mailJob" xmlns="http://www.springframework.org/schema/batch">
<step id="step1" xmlns="http://www.springframework.org/schema/batch">
<tasklet>
<chunk reader="itemReader" processor="itemProcessor" writer="itemWriter" commit-interval="5" skip-limit="100">
<skippable-exception-classes>
<include class="java.lang.RuntimeException" />
</skippable-exception-classes>
<!--
<fatal-exception-classes> <include class="org.springframework.mail.MailException"/> </fatal-exception-classes>
-->
</chunk>
</tasklet>
</step>
</job>
<bean id="itemReader" class="org.springframework.batch.item.database.JdbcCursorItemReader">
<property name="sql" value="select ID, NAME, EMAIL from USERS" />
<property name="rowMapper">
<bean class="org.springframework.jdbc.core.BeanPropertyRowMapper">
<property name="mappedClass" value="org.springframework.batch.sample.domain.mail.User" />
</bean>
</property>
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="itemWriter" class="org.springframework.batch.item.mail.SimpleMailMessageItemWriter">
<property name="mailSender" ref="mailSender" />
<property name="mailErrorHandler" ref="loggingMailErrorHandler" />
</bean>
<bean id="itemProcessor" class="org.springframework.batch.sample.domain.mail.internal.UserMailItemProcessor" />
<bean id="loggingMailErrorHandler" class="org.springframework.batch.sample.domain.mail.internal.TestMailErrorHandler" />
<bean id="mailSender" class="org.springframework.batch.sample.domain.mail.internal.TestMailSender">
<property name="subjectsToFail">
<list>
<value>John Adams's Account Info</value>
<value>James Madison's Account Info</value>
</list>
</property>
</bean>
</beans>

View File

@@ -28,6 +28,6 @@ log4j.appender.chainsaw.layout=org.apache.log4j.xml.XMLLayout
#log4j.logger.org.springframework.orm=debug
### debug your specific package or classes with the following example
log4j.logger.org.springframework.jdbc=debug
log4j.logger.org.springframework.batch=debug
log4j.logger.org.springframework.jdbc=info
log4j.logger.org.springframework.batch=info
log4j.logger.org.springframework.batch.sample=debug