how to run async batch job in batch-int:job-launching-gateway?

Firstly thanks for attention,

I combined spring integration and spring batch in my project, i want to launch jobs in asynchronous mode in batch-int:job-launching-gateway, my means is that each message in input channel launch job in asynchronous and not wait util to complete the jobs,my code is:

 <batch-int:job-launching-gateway request-channel="outboundJobRequestChannel"
                                     reply-channel="jobLaunchReplyChannel"/>

Update:

Thanks for @Nenad for help me, i defined JobRepository and JobLauncher in my configuration as bellow code :

@Bean
    public MapJobRepositoryFactoryBean jobRepositoryFactoryBean() {
        MapJobRepositoryFactoryBean fb = new MapJobRepositoryFactoryBean();
        return fb;
    }
 @Bean
    public JobLauncher jobLauncher() throws Exception {
        final SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
        jobLauncher.setJobRepository(jobRepositoryFactoryBean().getObject());
        final SimpleAsyncTaskExecutor simpleAsyncTaskExecutor = new SimpleAsyncTaskExecutor();
        jobLauncher.setTaskExecutor(simpleAsyncTaskExecutor);
        return jobLauncher;
    }

but not worked ,and thrown bellow exception:

Exception in thread "SimpleAsyncTaskExecutor-20" java.lang.NullPointerException
    at org.springframework.batch.core.repository.dao.MapJobExecutionDao.synchronizeStatus(MapJobExecutionDao.java:158)
    at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:161)
    at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
    at com.sun.proxy.$Proxy18.update(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:127)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
    at com.sun.proxy.$Proxy18.update(Unknown Source)
    at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:351)
    at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:135)
    at java.lang.Thread.run(Thread.java:745)

Answers


It might be easier to simply change outboundJobRequestChannel to an ExecutorChannel. See the documentation and here.


Need Your Help

How to add a button with border to storyboard in Xcode 6

ios objective-c xcode ios8 xcode6

I wanna create a button with border in Xcode 6. For instance, I want it to look like the buttons from this library - https://github.com/a1anyip/AYVibrantButton - without any special visual effects....

No C# 6.0 in Visual Studio 2015 CTP?

c# visual-studio visual-studio-2015 roslyn c#-6.0

I have just created a new VM on Azure (using the image provided by the Azure team from the gallery) with CTP version of the upcoming Visual Studio 2014 that appeared yesterday online to test it and

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.