Announcement Announcement Module
No announcement yet.
All at sea with Spring Batch Integration Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • All at sea with Spring Batch Integration

    Greetings fellow batchonauts

    I am writing software to propagate changes to user accounts across several different external systems. I have used Spring Integration to acquire user data from a source system, resolve user account metadata and create a Message containing all the data required to batch update a specific external system. At that point it's over to Spring Batch.

    The messages that emerge from Integration come from a custom message splitter. The message header is the name of the target external system and the payload is a Collection of beans. The splitter returns this:
    Using this code:
    Collection<Message<List<UserUpdateBean>>> messages = new ArrayList<Message<List<UserUpdateBean>>>();
    MessageBuilder<List<UserUpdateBean>> messageBuilder = MessageBuilder.withPayload(messagePayload);
    messageBuilder.setHeader(, recipientHeaderValue);
    Message<List<UserUpdateBean>> message =;
    Where the user bean looks like this:
    public class UserUpdateBean {
       private String userID;
       private boolean isNewUser;
       private String userName;
       private String screenName;
       private String firstName;
       private String middleName;
       private String lastName;
       private Date birthday;
       private Long employeeNumber;
       private String emailAddress;
       private String jobTitle;
       private String jobClass;
       private String greeting;
    A custom message router sends a Message<List<UserUpdateBean>> to a specific channel based on the header value. The header value contains the name of the target system.. The channel is used only for updates for a specific external system.
    <si:header-value-router input-channel="outboundUserUpdateRoutingChannel" header-name="${}">
    	<si:mapping value="${message.header.value.loginmanagement}" channel="outboundLoginManagementUserUpdateChannel" />
    	<si:mapping value="${message.header.value.arvalonline}" channel="outboundArvalOnlineUserUpdateChannel" />
    	<si:mapping value="${message.header.value.card}" channel="outboundCardUserUpdateChannel" />
    	<si:mapping value="${}" channel="outboundDriveUserUpdateChannel" />
    This is what I am aiming for:
    1. Batch receives a Message<List<UserUpdateBean>>
    2. An ItemReader implementation gets the message payload (List<UserUpdateBean>) and chunk-reads the UserUpdateBeans from the List
    3. An ItemProcessor implementation does some further processing (optional step)
    4. An ItemWriter implementation puts values from each UserUpdateBean in the chunk into a SQL batch update statement and executes it

    This is my (incomplete) Batch configuration:
    public JobLaunchingMessageHandler jobLaunchingMessageHandler() {
    	JobLaunchingMessageHandler jobLaunchingMessageHandler = new JobLaunchingMessageHandler(this.jobLauncher);
    	return jobLaunchingMessageHandler;
    <bean id="jobRegistry" class="" />
    <bean id="jobLauncher" class="">
    	<property name="jobRepository" ref="jobRepository" />
    <bean id="jobRegistryBeanPostProcessor" class="">
    	<property name="jobRegistry" ref="jobRegistry" />
    <bean id="jobRepository" class="">
    	<property name="dataSource" ref="ulmDataSource" />
    	<property name="transactionManager" ref="ulmDataSourceTransactionManager" />
    <si:service-activator input-channel="outboundLoginManagementUserBatchUpdateChannel" output-channel="loginManagementUserUpdateStatusChannel" ref="jobLaunchingMessageHandler" />
    The problem is that I just cannot see how to link Integration and Batch together using Batch Integration.

    The message arrives in JobLaunchingMessageHandler service activator. Then what? I don't know where the message ends up or how to the message's payload into the ItemReader. The message seems to disappear into a black hole.

    I have scoured Google and read the Batch manual plus other documentation a hundred times but I can't make sense of it. I am completely stuck.