Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple CompositeItemReader analagous to CompositeItemWriter and CompositeItemProcessor #757

Closed
spring-projects-issues opened this issue Nov 12, 2019 · 1 comment

Comments

@spring-projects-issues
Copy link
Collaborator

Elliot Korte opened BATCH-2857 and commented

There may be a reason for this, but why doesn't there exist a composite item reader? It would be useful to chain different readers in the same way as CompositeItemWriter and CompositeItemProcessor. There's a MultipleResourceItemReader but I'm wondering why does the only reader which uses this delegate pattern have the restriction of being "ResourceAware"?


No further details from BATCH-2857

@fmbenhassine fmbenhassine changed the title Simple CompositeItemReader analagous to CompositeItemWriter and CompositeItemProcessor [BATCH-2857] Simple CompositeItemReader analagous to CompositeItemWriter and CompositeItemProcessor Sep 15, 2023
@fmbenhassine
Copy link
Contributor

There may be a reason for this, but why doesn't there exist a composite item reader? It would be useful to chain different readers in the same way as CompositeItemWriter and CompositeItemProcessor.

I couldn't find any context about why there is no composite item reader, but I guess the main reasons are how to respect the "forward-only" contract of an item reader and how to deal with restartability. Similar to the composite writer, a composite reader could delegate reading items to a list of delegates in their registration order (once a delegate returns null, it moves to the next delegate, and so on), but making this kind of composition restartable is quite challenging.

An example of such a composite item reader can be found here. I would be grateful for anyone who gives it a try and share feedback here. A typical use case for this is reading the same data from different datasources for aggregation (the example shows a composite reader that delegates to 3 readers, reading the same data from two files and a database table).

There's a MultipleResourceItemReader but I'm wondering why does the only reader which uses this delegate pattern have the restriction of being "ResourceAware"?

I see no obvious reason for that, but since items could come from different resources, one should probably be able to know the original resource from which an item was read.

@fmbenhassine fmbenhassine removed the status: waiting-for-triage Issues that we did not analyse yet label Sep 15, 2023
@fmbenhassine fmbenhassine added this to the 5.2.0 milestone Sep 15, 2023
@fmbenhassine fmbenhassine modified the milestones: 5.2.0, 5.2.0-M2 Sep 16, 2024
FBibonne pushed a commit to FBibonne/spring-batch that referenced this issue Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants