Skip to content

Instantly share code, notes, and snippets.

View fmbenhassine's full-sized avatar

Mahmoud Ben Hassine fmbenhassine

View GitHub Profile
@fmbenhassine
fmbenhassine / SynchronizedItemStreamWriterTest.java
Created March 27, 2019 21:08
#SpringBatch SynchronizedItemStreamWriterTest PR#665 for BATCH-2762
package org.springframework.batch.item.support;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@fmbenhassine
fmbenhassine / ConsumerItemWriter.java
Created January 29, 2019 22:12
#SpringBatch java.util.function components
package org.springframework.batch.item.function;
import java.util.List;
import java.util.function.Consumer;
import org.springframework.batch.item.ItemWriter;
import org.springframework.util.Assert;
public class ConsumerItemWriter<T> implements ItemWriter<T> {
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@fmbenhassine
fmbenhassine / DemoExitCodeApplication.java
Created July 21, 2018 16:29
Custom exit code with boot #SpringBatch
package com.example.demoexitcode;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoExitCodeApplication {
public static void main(String[] args) {
System.exit(
@fmbenhassine
fmbenhassine / PartitionJobSample.java
Created June 7, 2018 13:44
Spring Batch local partitioning sample #SpringBatch
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@fmbenhassine
fmbenhassine / MyJob.java
Last active May 17, 2020 20:54
Spring Batch example of how to use a ClassifierCompositeItemWriter #SpringBatch https://stackoverflow.com/questions/53377660
package org.springframework.batch.sample;
import java.util.Arrays;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
@fmbenhassine
fmbenhassine / DemoValidationApplication.java
Last active October 17, 2021 12:42
Spring Batch Bean Validation example #SpringBatch
package com.example.demovalidation;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoValidationApplication {
public static void main(String[] args) {
SpringApplication.run(DemoValidationApplication.class, args);
@fmbenhassine
fmbenhassine / RemoteChunkingJobFunctionalTests.java
Last active May 24, 2018 20:37
Spring Batch "remote" chunking sample with embedded JMS broker #SpringBatch
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@fmbenhassine
fmbenhassine / FileIngestionJobConfiguration.java
Last active July 18, 2018 20:06
Spring Batch File ingestion job sample #SpringBatch
package io.github.benas.sbi;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import javax.sql.DataSource;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;