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

Read lock options for files are ignored #1105

Closed
philschaller opened this issue Apr 19, 2020 · 10 comments · Fixed by #1110
Closed

Read lock options for files are ignored #1105

philschaller opened this issue Apr 19, 2020 · 10 comments · Fixed by #1110
Assignees

Comments

@philschaller
Copy link
Contributor

Describe the bug
I created a minimal integration test in a separate branch of my fork:
https://github.com/philschaller/camel-quarkus/tree/readLockFails

The route in the test should only move files with a minimal length. But it moves an empty file. Debugging the application showed that it always falls back to generic behavior in GenericFileExclusiveReadLockStrategy.getExclusiveReadLockStrategy.

I also tried to convince the route to use the right read lock strategy by setting the option
exclusiveReadLockStrategy=org.apache.camel.component.file.strategy.FileChangedExclusiveReadLockStrategy.

But it does not change the result. Actually, it does not even load that class, thus it may be some class loading issue. But that is only a wild guess.

Expected behavior
Respect the read locks.

Workaround
No general one to my knowledge. But I can mitigate the problem in my application.

Environment
Camel Quarkus 1.0.0-M6 and master branch
JDK 11

@lburgazzoli
Copy link
Contributor

does this happen in native or jvm mode ?

@philschaller
Copy link
Contributor Author

Hi
JVM mode, never tried it in native mode. I am not sure if it ever worked with Quarkus or Camel 3.x...or if I am doing something completely wrong.

@lburgazzoli
Copy link
Contributor

lburgazzoli commented Apr 20, 2020

I think you need to reference a bean from a registry, like with

exclusiveReadLockStrategy=#myStrategy

where myStrategy is the name of a bean inf the camel registry or as alternative something like:

exclusiveReadLockStrategy=#class:org.apache.camel.component.file.strategy.FileChangedExclusiveReadLockStrategy

@davsclaus
Copy link
Contributor

readLock=change is actually one of the out of the box implementations, so you should NOT use it together with exclusiveReadLockStrategy as that is for using a custom implementation. And if you really want to use that, then use the style luca says with the # lookup for bean id.

@philschaller
Copy link
Contributor Author

I can try that. But even without any explicit strategy it should work. While debugging it never cared about readLock=changed.

@philschaller
Copy link
Contributor Author

Just to make this clear: it shows the same behavior without the option exclusiveReadLockStrategy.

While debugging the test FileTest.fileReadLock_minLength() it always hits GenericFileProcessStrategyFactory.getExclusiveReadLockStrategy and returns null. I would expect it to run through FileProcessStrategyFactory.getExclusiveReadLockStrategy and parse readLock and readLockMinLength.

@davsclaus
Copy link
Contributor

Works on camel master (not camel-quarkus) so if there is something wrong then its in camel-quarkus.

Its the FileProcessStrategyFactory that should be used as it has the file only strategy such as changed, so you are debugging the wrong class.

@philschaller
Copy link
Contributor Author

Thanks for testing with Camel!

I would like to debug FileProcessStrategyFactory, but it is never called...

@philschaller
Copy link
Contributor Author

Another short round of debugging revealed this:
The strategy factory is supposed to be found in the method GenericFileEndpoint.createGenericFileStrategy. But the the factory finder resolver method FastFactoryFinderResolver.findClass does not find a corresponding entry in its classMap variable for the key META-INF/services/org/apache/camel/component/strategy.factory.file.

I do not know if the key itself is correct, but there is not even a class FileProcessStrategyFactory in the classMap. Thus it falls back to the GenericFileProcessStrategyFactory which means that this setup will never care about the readLock=changed.

Something is broken. Either my setup or this part of class loading in Camel Quarkus. I tried it with two different systems (Windows, Linux).

@lburgazzoli
Copy link
Contributor

@philschaller ok I see what the problem could be, do you mind sending a PR with a filing test ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants