spring-batch | Spring Integration ActiveMQ Spring-Data H2 | Model View Controller library

 by   create1st Java Version: Current License: Apache-2.0

kandi X-RAY | spring-batch Summary

kandi X-RAY | spring-batch Summary

spring-batch is a Java library typically used in Architecture, Model View Controller, Spring Boot, Spring, Swagger applications. spring-batch has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can download it from GitHub.

Spring-Boot + Spring-Batch + Spring Integration + ActiveMQ + Spring-Data + H2 + Actuator + Swagger - Demo App
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              spring-batch has a highly active ecosystem.
              It has 4 star(s) with 4 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              spring-batch has no issues reported. There are no pull requests.
              It has a positive sentiment in the developer community.
              The latest version of spring-batch is current.

            kandi-Quality Quality

              spring-batch has 0 bugs and 0 code smells.

            kandi-Security Security

              spring-batch has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              spring-batch code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              spring-batch is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              spring-batch releases are not available. You will need to build from source code and install.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              spring-batch saves you 629 person hours of effort in developing the same functionality from scratch.
              It has 1462 lines of code, 129 functions and 45 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed spring-batch and discovered the below as its top functions. This is intended to give you an instant insight into spring-batch implemented functionality, and help decide if they suit your requirements.
            • Process ticket
            • Gets the text content
            • Gets the tag
            • Sets the content of the embed
            • Import ticket processor
            • Check ticket type
            • Gets the ticket type
            • H2 server
            • Creates a m2 console mappings
            • Add ticket writer
            • Updates the reader
            • Gets the metric value
            • Handle a new ticket
            • Before job import job
            • Open the reader
            • Create message source for file
            • Start jmx reporter
            • Create api info bean
            • Creates JMS template
            • Embedded mq broker service
            • Translate a message to a job
            • Read items from the stream
            • Defines default poller
            • Create ticket import job execution listener
            • Post job import job
            • Process item
            Get all kandi verified functions for this library.

            spring-batch Key Features

            No Key Features are available at this moment for spring-batch.

            spring-batch Examples and Code Snippets

            No Code Snippets are available at this moment for spring-batch.

            Community Discussions

            QUESTION

            Spring batch AbstractJob Encountered Fatal Error - could not serialize the execution context
            Asked 2021-Jun-12 at 18:44

            I'm getting this error because one of the fields in my domain class is a LocalDate. Stack trace below. Jackson is complaining about Java 8 date/time not being supported by default, but Spring Boot 2.5 comes with com.fasterxml.jackson.datatype:jackson-datatype-jsr310. How do I get Spring Batch to support my LocalDate field in my domain class?

            If I change the field to be a java.util.Date it works perfectly.

            Thanks!

            ...

            ANSWER

            Answered 2021-Jun-10 at 03:14

            You can add serializer and deserializer for it.

            Source https://stackoverflow.com/questions/67913592

            QUESTION

            Copy header tag in xml spring batch application
            Asked 2021-Jun-10 at 08:14

            I am using spring-batch in spring-boot application. The Spring Boot version is 2.3.3.RELEASE.

            What I intend to achieve

            I have to read a xml file containing thousands of Transactions with header tag (fileInformation). Do some business logic on transaction and then write the file back with the updated values in transaction. I am using StaxEventItemReader for reading the file and StaxEventItemWriter for writing to the file. Then i have couple of ItemProcessors for handling the business logic. Xml file looks like :

            ...

            ANSWER

            Answered 2021-Jun-10 at 07:38

            You step is doing too much. I would beak things down to two steps:

            • Step 1: extracts the file information header and puts it in the job execution context
            • Step 2: reads the file information header from the execution context and uses it in whatever step-scoped bean needed for that step (for example the stax callback in your case)

            Here is a quick example:

            Source https://stackoverflow.com/questions/67909123

            QUESTION

            Spring Batch multiple datasources and ChainedTransactionManager risks
            Asked 2021-Jun-07 at 12:58

            I am doing a study on the feasibility of a Spring Batch composed of two datasources. A SQL datasource for the Spring Batch metadata and a MongoDB datasource (with transactional use) for the business data. The transactional aspect raises several questions here.

            The following topic: Spring batch with MongoDB and transactions and related resources provide a number of answers to my questions. The answer mentions the use of Spring's JtaTransactionManager to manage distributed transactions on the two datasources. This technique uses the 2PC protocol. It is also the most robust solution if I understood correctly. https://www.infoworld.com/article/2077963/distributed-transactions-in-spring--with-and-without-xa.html?page=2

            On the other hand, I found some resources about Spring's ChainedTransactionManager. This technique uses the best effort 1PC protocol. This solution is less robust, if I understand correctly the system can be in an inconsistent state in case of a problem in the infrastructure (network failure for example). The ChainedTransactionManager has the advantage of being easier to implement and offers better performance. I saw that it is deprecated https://github.com/spring-projects/spring-data-commons/issues/2232.

            What are the concrete risks of using the ChainedTransactionManager in a Spring Batch? In case of an error, can I have inconsistencies between the Spring batch metadata and the business data in Mongo? I imagine there are also considerations to take into account with retry or chunk skip strategies?

            Thanks a lot for your help.

            ...

            ANSWER

            Answered 2021-Jun-07 at 12:58

            In case of an error, can I have inconsistencies between the Spring batch metadata and the business data in Mongo?

            Yes, that's is the risk you should be aware of.

            A common technique to avoid that is to disable state management and use the process indicator pattern. You can find an example here.

            Source https://stackoverflow.com/questions/67841107

            QUESTION

            Spring Batch - FlatFileItemWriter Error 14416: Stream is already closed
            Asked 2021-Jun-02 at 12:35

            Basically I have a Spring Batch that queries a Database and implements Partitioner to get the Jobs, and assign the Jobs to a ThreadPoolTaskExecutors in a SlaveStep.

            The Reader reads (Job) from the Database. The Writer loads the data into a csv file in an Azure Blob Storage.

            The Job Partitioner and Reader works fine. The Writer writes to one file, then it closes, and the other jobs cannot finish because the stream is closed. I get the following error:

            ...

            ANSWER

            Answered 2021-Jun-02 at 07:56

            You did not share the entire stack trace to see when this error happens exactly, but it seems that the close method is called more than once. I think this is not due to a concurrency issue, as I see you are using one writer per thread in a partitioned step. So I would make this method "re-entrant" by checking if the output stream is already closed before closing it (there is no isClosed method on an output stream, so you can use a custom boolean around that).

            That said, I would first confirm that the close method is called twice and if so, investigate why is that and fix the root cause.

            Source https://stackoverflow.com/questions/67793915

            QUESTION

            How to process List of items in Spring batch using Chunk based processing| Bulk processing items in Chunk
            Asked 2021-May-31 at 08:55

            I am trying to implement a Spring batch job where in order to process a record , it require 2-3 db calls which is slowing down the processing of records(size is 1 million).If I go with chunk based processing it would process each record separately and would be slow in performance. So, I need to process 1000 records in one go as bulk processing which would reduce the db calls and performance would increase. But my question is If I implement Tasklet then I would lose the functionality of restartability and retrial/skip features too and if implemented using AggregateInputReader I am not sure what would be the impact on restartability and transaction handling. As per the below thread AggregateReader should work but not sure its impact on transaction handling and restartability in case of failure:

            Spring batch: processing multiple record at once

            ...

            ANSWER

            Answered 2021-May-31 at 08:55

            The first extension point in the chunk-oriented processing model that gives you access to the list of items to be written is the ItemWriteListener#beforeWrite(List items). So if you do not want to enrich items one at a time in an ItemProcessor, you can use that listener to do the enrichment for the entire chunk at once.

            Source https://stackoverflow.com/questions/67742007

            QUESTION

            Creating job instances concurrently causes MySQL deadlock using default isolation level?
            Asked 2021-May-30 at 03:02

            Recently we run a test which created different Spring batch job instances concurrently (e.g 10 threads in parallel, job names are similar but different, e.g with the same prefix). And it's fairly easy to trigger deadlockerror reported from MySQL exception is

            org.springframework.dao.DeadlockLoserDataAccessException: PreparedStatementCallback; SQL [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; Deadlock found when trying to get lock; try restarting transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:267) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1443) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:633) at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:862) at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:917) at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:922) at org.springframework.batch.core.repository.dao.JdbcJobInstanceDao.createJobInstance(JdbcJobInstanceDao.java:120) at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:140) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)

            We searched for existing reports regarding to deadlock and find that some are specific to SQLServer like this: (https://github.com/spring-projects/spring-batch/issues/1448). After analysis of the isolation level used for creating jobs(SERIALIZABLE) and the operation sequence, we think the deadlock could be trigged as following:

            1、before creating a job instance, the code will first query batch_job_instance table to check if the instance already exists(about 3 times), under SERIALIZABLE mode, this will hold shared next-key lock (https://dev.mysql.com/doc/refman/5.7/en/innodb-next-key-locking.html) in MySQL which lock records that are in scope related to the job name.

            2、thread 2 want to create job2 and insert a row in batch_job_instance and thread 3 want to do the same thing, as both threads hold the same read next-key lock and the rows that need to be inserted are also in the key scope, the deadlock will happen.

            Refer to the link here(https://docs.spring.io/spring-batch/trunk/apidocs/org/springframework/batch/core/repository/support/AbstractJobRepositoryFactoryBean.html#setIsolationLevelForCreate-java.lang.String-), we tried changing the isolation level to REPEATABLE_READ and this worked without any deadlock.

            So the key question here is :

            Is setting isolation level to REPEATABLE_READ the recommended solution here and is there any side effect of this solution as it's not set as default option ?

            Thanks a lot!

            ...

            ANSWER

            Answered 2021-May-28 at 13:08

            we tried changing the isolation level to REPEATABLE_READ and this worked without any deadlock.

            So the key question here is : Is setting isolation level to REPEATABLE_READ the recommended solution here and is there any side effect of this solution as it's not set as default option ?

            Yes, that's the way to go. If SERIALIZABLE is too aggressive, you can use a less aggressive isolation level for the job repository. That's why the setIsolationLevelForCreate is provided. This is actually documented in its Javadoc:

            Source https://stackoverflow.com/questions/67731847

            QUESTION

            which Spring Batch version is recommended for production, 4.2.7 or 4.3.3?
            Asked 2021-May-27 at 08:33

            we plan to use Spring Batch for mission critical production batching system. And I am wondering which version we should choose now?

            From the version history in github(https://github.com/spring-projects/spring-batch/tags): version 4.2.7 is marked with .RELEASE, while 4.3.3 is not.

            So the questions are:

            1、what's the difference regarding the versions with or without .RELEASE ending, is the ".RELEASE" ending verison more stable?

            2、which version is recommended for production now ?
            Thanks a lot!

            ...

            ANSWER

            Answered 2021-May-27 at 08:33

            Both are production ready releases, one for the 4.2 line and the other for the 4.3 line. I recommend using the latest 4.3 as it has an extended support lifetime. Spring Batch follows the same support terms as Spring Boot, and each version will be supported as long as the latest Spring Boot version that brings it is supported, see https://github.com/spring-projects/spring-boot/wiki/Supported-Versions.

            For example:

            • the latest Spring Boot version that brings Spring Batch 4.2 is 2.3 which will be OSS supported until May 2021.
            • The latest Spring Boot version that brings Spring Batch 4.3 is 2.5 which will be OSS supported until May 2022.
            • etc

            Spring Boot 2.6 is expected on November 2021 and will likely bring Spring Batch 4.3 as well, which extends the OSS support for Spring Batch 4.3 for another year. So I recommend using the latest version from 4.3 to benefit from a longer support period since you are planning to use it in production. FTR, there is an ongoing effort to update the website/wiki with all these support details across the portfolio, so keep tuned.

            In regard to the version name scheme, we (the Spring engineering team) have decided to switch from the old naming scheme (.BUILD-SNAPSHOT, .RELEASE, etc) to a new naming scheme. This has been announced on our blog here: Updates to Spring Versions.

            Source https://stackoverflow.com/questions/67716589

            QUESTION

            Spring Batch / Azure Storage account blob resource [container"foo", blob='bar'] cannot be resolved to absolute file path
            Asked 2021-May-26 at 15:47

            I am trying to write to an Azure Storage using Spring.

            I am configuring the resource inside a Bean instead of Autowiring it from the Class.

            ...

            ANSWER

            Answered 2021-May-26 at 02:38

            The searchLocation should start with azure-blob:// or azure-file://. The "blob" in your comment is incorrect.

            azure-blob://foo/bar.csv means the "bar.csv" blob in "foo" container. Please check your storage, make sure the blob exists.

            For example, my blob URL is https://pamelastorage123.blob.core.windows.net/pamelac/test.txt, so azure-blob://pamelac/test.txt is right.

            StorageExampleApplication.java:

            Source https://stackoverflow.com/questions/67689536

            QUESTION

            Scope 'job' is not active for the current thread, No context holder available for job scope Spring-Batch
            Asked 2021-May-17 at 08:31

            In my Spring batch job, I'm trying to share data between steps using JobExecutionContext, which works only if i keep the steps single threaded as follows:

            ...

            ANSWER

            Answered 2021-May-17 at 08:31

            I'm trying to share data between steps using JobExecutionContext, which works only if i keep the steps single threaded

            Relying on the execution context to share data between multi-threaded steps is incorrect, because the keys will be overridden by concurrent threads. The reference documentation explicitly mentions to turn off state management in multi-threaded environment:

            • Javadoc: remember to use saveState=false if used in a multi-threaded client
            • Reference doc: it is not recommended to use job-scoped beans in multi-threaded or partitioned steps

            That said, I don't see what key could be shared from a multi-threaded step to the next step (as threads are executed in parallel), but if you really need to do that, you should use another method like defining a shared bean that is thread safe.

            Source https://stackoverflow.com/questions/67557818

            QUESTION

            Minimum Spring-batch and spring-context version compatible with Java 11?
            Asked 2021-May-11 at 07:49

            I need to upgrade my maven project to Java 11, so I am wondering:

            1. What is the min version of Spring Framework and spring-batch version supported in Java 11?
            2. What to be change in the pom?

            As of now I know:

            1. My project is not a spring-boot.
            2. I know the Spring version should be at least 5.1.
            3. ...

            ANSWER

            Answered 2021-May-11 at 07:49

            I know the Spring version should be at least 5.1

            2.1.9.RELEASE

            You seem to be upgrading Spring Batch from v2. Since your Spring version should be at least v5.1, you need to upgrade Spring Batch to v4 (which is based on Spring Framework v5) and requires Java 8 at a minimum. So the answer to your question about the minimum Java version is Java 8, but you should be able to use Java 11 if you want.

            Source https://stackoverflow.com/questions/67468677

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install spring-batch

            You can download it from GitHub.
            You can use spring-batch like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the spring-batch component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/create1st/spring-batch.git

          • CLI

            gh repo clone create1st/spring-batch

          • sshUrl

            git@github.com:create1st/spring-batch.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link