Skip to content

Conversation

@artembilan
Copy link
Member

Fixes: #7971

Extend a FileReadingMessageSource.directory logic to the SpEL expression to evaluate on each scan

  • Introduce an internal record DirFile to keep the File and scanned directory per file
  • Propagate a new directory down to the WatchServiceDirectoryScanner and restart it
  • Calculate a root directory from the failed Message we offer back to the queue
  • Fix tests for a new FileReadingMessageSource.directoryExpression property
  • Expose a Supplier<File> configuration for Java DSL
  • Modify FileTests.MyService.pollDirectories() for a Supplier<File> configuration
  • Document this new feature

…sion`

Fixes: spring-projects#7971

Extend a `FileReadingMessageSource.directory` logic to the SpEL expression
to evaluate on each scan

* Introduce an internal `record DirFile` to keep the `File` and scanned directory
per file
* Propagate a new directory down to the `WatchServiceDirectoryScanner`
and restart it
* Calculate a root directory from the failed `Message` we offer back to the queue
* Fix tests for a new `FileReadingMessageSource.directoryExpression` property
* Expose a `Supplier<File>` configuration for Java DSL
* Modify `FileTests.MyService.pollDirectories()` for a `Supplier<File>` configuration
* Document this new feature
Copy link
Contributor

@cppwfs cppwfs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

My usual annoying nitpicks ;-)

}

/**
* Specify a SpEL expression for an input directory.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick. But isn't it an implementation of Expression instead of a single implementation of SpELExpression?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The framework is called SpEL and because of many Expression classes in the wild it would be better to be specific in our JavaDocs of what exactly framework an Expression instance is expected for this setter.
We also use SpEL term everywhere else, including docs, so it should not be confusing what is expected.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! That makes sense. Just wanted to make sure.

StandardIntegrationFlow integrationFlow = IntegrationFlow
.from(Files.inboundAdapter(() -> directories[index.getAndIncrement() % directories.length])
.recursive(true),
e -> e.poller(p -> p.fixedDelay(100))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, Was the drop to a delay from 1000 milli to 100 milli on purpose?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I'm very suspicious when test is slower than it should be.
Like in this case, we've got before a delay of one second in between reading from those directories we iterate in the supplier.
Such a delay is not justified for this test goal.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Just wanted to make sure!

Copy link
Contributor

@cppwfs cppwfs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM .
I love the addition!

@cppwfs cppwfs merged commit 72960e1 into spring-projects:main Oct 14, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamically change the input directory for inbound channel adapter [INT-4025]

2 participants