codecentric/spring-boot-starter-batch-web

Need a method to set serializer for JobRepository and JobExplorer

brunnels opened this issue · 3 comments

There's a bug described here with databases like postgres and sql server that requires setting the serializer on the JobRepositoryFactoryBean and JobExplorerFactoryBean to Jackson2ExecutionContextStringSerializer. I don't see a way to do this via TaskExecutorBatchConfigurer other than overriding much of it.

@brunnels Due to cleaning up issues list: Is this custom serializer needed any more?

I need this feature. Our jobs are not restartable and we pass large objects between steps. Some of them are job scope and behind GCLIB proxies (obviously they cannot be recreated by Jackson deserializer).

This piece does great job to disable "enterprisy" feature of Spring Batch:

public class FakeSerializer implements ExecutionContextSerializer {
    @Override
    public Map<String, Object> deserialize(InputStream inputStream) throws IOException {
        return new HashMap<>();
    }
    @Override
    public void serialize(Map<String, Object> object, OutputStream outputStream) throws IOException {
        outputStream.write("fake".getBytes(StandardCharsets.US_ASCII));
    }
}

As @brunnels has written it is impossible to inject FakeSerializer without coping entire implementation of BasicBatchConfigurer or similar.

All implementations of BatchConfigurer don't share any code except rudimentary JpaBatchConfigurer ((

Implemented with 65ce01a
Just add bean of type ExecutionContextSerializer in your Spring application context.