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

Q: RuleBean execution results in full scan? #175

Open
willks opened this issue Dec 19, 2019 · 7 comments
Open

Q: RuleBean execution results in full scan? #175

willks opened this issue Dec 19, 2019 · 7 comments

Comments

@willks
Copy link

willks commented Dec 19, 2019

Hi,
Just a small question - but does every invocation of "SpringAwareRuleBookRunner" result in a full package scan? These are the logs I am seeing:

2019-12-19 13:24:13.589  INFO 15322 --- [atcher-worker-2] org.reflections.Reflections              : Reflections took 3 ms to scan 1 urls, producing 4 keys and 9 values 
2019-12-19 13:25:48.746  INFO 15322 --- [atcher-worker-7] org.reflections.Reflections              : Reflections took 2 ms to scan 1 urls, producing 4 keys and 9 values 
2019-12-19 13:26:37.353  INFO 15322 --- [atcher-worker-3] org.reflections.Reflections              : Reflections took 3 ms to scan 1 urls, producing 4 keys and 9 values 
2019-12-19 13:30:10.100  INFO 15322 --- [atcher-worker-2] org.reflections.Reflections              : Reflections took 2 ms to scan 1 urls, producing 4 keys and 9 values 
2019-12-19 13:31:39.640  INFO 15322 --- [atcher-worker-5] org.reflections.Reflections              : Reflections took 2 ms to scan 1 urls, producing 4 keys and 9 values 
2019-12-19 13:31:39.926  INFO 15322 --- [atcher-worker-8] org.reflections.Reflections              : Reflections took 3 ms to scan 1 urls, producing 4 keys and 9 values 
2019-12-19 13:32:26.740  INFO 15322 --- [atcher-worker-4] org.reflections.Reflections              : Reflections took 2 ms to scan 1 urls, producing 4 keys and 9 values 
2019-12-19 13:32:53.214  INFO 15322 --- [atcher-worker-1] org.reflections.Reflections              : Reflections took 2 ms to scan 1 urls, producing 4 keys and 9 values 
2019-12-19 13:35:38.264  INFO 15322 --- [atcher-worker-2] org.reflections.Reflections              : Reflections took 2 ms to scan 1 urls, producing 4 keys and 9 values 

Just a question.

Thanks for a nice framework for rules

@Clayton7510
Copy link
Collaborator

Yes, it does. This is done for thread safety. Although, perhaps there is a more elegant way to solve the problem.

@Clayton7510
Copy link
Collaborator

I'm looking into switching this to a single scan. But the instantiation of the POJOs that are found in the scan will still take place on every run and there is a little reflection involved there since it transforms a POJO class representation into a Rule via an adapter.

@Clayton7510
Copy link
Collaborator

There is an update in 0.12-SNAPSHOT that has a fix for this.

@allenvpn312
Copy link

@Clayton7510 is there a way to turn off scan logging?

@willks
Copy link
Author

willks commented Feb 28, 2020

Sorry I didn't post this earlier. I worked around it before the 0.12-SNAPSHOT was posted. This is my code in Kotlin for setting up my rules. They have to be added in order of execution:

        val pojoRules = listOf<Class<*>>(
                EmptyPayloadRule::class.java,
                ValidJsonRule::class.java,
                TemperatureDeviceRule::class.java,
                UnknownRule::class.java)
        return RuleBookRunner4PojoClasses(pojoRules) as RuleBook<MyReturnEntityType>

This will avoid full scans, but the onus is on setting up order properly. Everything worked well. We're running these rules potentially hundreds/thousands of times per second through Kotlin Coroutines. It's held up well.

As a side note - this framework has been awesome for us. It allowed us to remove business rules into small, distinct, clear rules that are easy to update. The rest of our code is just calling out to these rules. I have smashed it with hundreds of threads simulating thousands of concurrent users. Didn't skip a beat!

One of my favourite projects on Github by far. Good work has been done here, much appreciated.

Thanks

@willks
Copy link
Author

willks commented Feb 28, 2020

@Clayton7510 With all that said, I found a work-around. I think we can close this issue out from my perspective.

@azell
Copy link
Contributor

azell commented Apr 21, 2020

Possible dupe of #155

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

4 participants