Announcement Announcement Module
Collapse
No announcement yet.
Log to database successfull process Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Log to database successfull process

    Where in the batch-job should we implement code/functionality for logging to database successfull process/failure of a job?

    I enclose the job-config we use
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:aop="http://www.springframework.org/schema/aop"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xmlns:p="http://www.springframework.org/schema/p"
    	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-2.0.xsd
    		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
    		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
    
        <description>This job imports payments from the accounting system</description>
        <import resource="classpath:/springAccountBalancerCore-configurer.xml"/>
        <import resource="classpath:/springAccountBalancerCore-dao.xml"/>
    
        <bean id="simpleJob"
            class="org.springframework.batch.core.configuration.JobConfiguration"
            abstract="true">
            <property name="restartable" value="false" />
            <property name="startLimit" value="-1"/>
        </bean>
    
    
        <bean parent="stepScope" />
    	<bean parent="jobConfigurationRegistryBeanPostProcessor" />
    
        <bean id="paymentImportJob" parent="simpleJob">
            <property name="steps">
                <bean id="step1"
                    class="org.springframework.batch.execution.step.RepeatOperationsStepConfiguration">
                    <property name="tasklet">
                        <bean class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
                            <property name="itemProvider">
                                <bean class="org.springframework.batch.item.provider.InputSourceItemProvider">
                                    <property name="inputSource" ref="fileInputSource" />
                                </bean>
                            </property>
                            <property name="itemProcessor">
                                <bean
                                    class="no.aftenposten.accountbalancer.batch.processor.PaymentImportLineProcessor">
                                    <property name="outputSource" ref="invoiceManagerOutputSource" />
                                    <property name="invoicingManager" ref="invoicingManager"/>
                                </bean>
                            </property>
                        </bean>
                    </property>
                    <property name="chunkOperations">
                        <bean class="org.springframework.batch.repeat.support.RepeatTemplate">
                            <property name="interceptors" ref="invoiceManagerOutputSource" />
                            <property name="completionPolicy">
                                <bean class="org.springframework.batch.repeat.policy.SimpleCompletionPolicy">
                                    <property name="chunkSize" value="1" />
                                </bean>
                            </property>
                        </bean>
                    </property>
                    <property name="stepOperations">
                        <bean class="org.springframework.batch.repeat.support.RepeatTemplate">
                            <property name="exceptionHandler">
                                <bean class="org.springframework.batch.repeat.exception.handler.SimpleLimitExceptionHandler"
                                    p:limit="0" p:useParent="true" p:type="java.lang.Exception" />
                            </property>
                        </bean>
                    </property>
                </bean>
            </property>
        </bean>
    
        <!-- This is a framework class that needs a delegate and also needs to be registered as a RepeatInterceptor in the chunk -->
        <bean id="invoiceManagerOutputSource"
            class="no.aftenposten.accountbalancer.batch.outputsource.InvoicingManagerOutputSource" >
            <property name="invoicingDao" ref="invoicingJdbcDao"/>
        </bean>
    
        <bean id="paymentLineMapper" class="no.aftenposten.accountbalancer.batch.mapper.PaymentFieldSetMapper" />
    
    	<bean id="paymentLineDescriptor"
    		class="org.springframework.batch.io.file.support.transform.DelimitedLineTokenizer">
    		<property name="delimiter" value=";"/>
    	</bean>
    
        <bean id="fileInputSource" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource">
    		<property name="resource"
    			value="classpath:paymentInput.txt" />
            <property name="tokenizer" ref="paymentLineDescriptor" />
            <property name="fieldSetMapper" ref="paymentLineMapper" />
    	</bean>
    
        <bean parent="customEditorConfigurer" />
    
    </beans>

  • #2
    There's places to do that, but I'm not sure I understand the use-case, since the repository already stores success and failure of an execution.

    Comment

    Working...
    X