Skip to content

FINERACT-1724: Making global configuration caching transaction bound - #3041

Merged
galovics merged 1 commit into
apache:developfrom
galovics:FINERACT-1724-47
Mar 14, 2023
Merged

FINERACT-1724: Making global configuration caching transaction bound#3041
galovics merged 1 commit into
apache:developfrom
galovics:FINERACT-1724-47

Conversation

@galovics

Copy link
Copy Markdown
Contributor

Description

Describe the changes made and why they were made.

Ignore if these details are present on the associated Apache Fineract JIRA ticket.

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per https://github.com/apache/fineract/#pull-requests

  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.

  • Create/update unit or integration tests for verifying the changes made.

  • Follow coding conventions at https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions.

  • Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes

  • Submission is not a "code dump". (Large changes can be made "in repository" via a branch. Ask on the developer mailing list for guidance, if required.)

FYI our guidelines for code reviews are at https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide.

@adamsaghy

Copy link
Copy Markdown
Contributor

@galovics Kindly asking you to check the failing tests and squash the commits!

@galovics
galovics marked this pull request as draft March 13, 2023 10:49
@galovics
galovics marked this pull request as ready for review March 13, 2023 16:00
@@ -29,6 +32,8 @@

public class ExtendedJpaTransactionManager extends JpaTransactionManager {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we really need this? Can't this be accomplished with https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/transaction/event/TransactionalEventListener.html (aka transaction bound events)? From a first look at this I'd say yes... if you want to keep those custom lifecycle callbacks then you just need to write a transaction event listener and do pretty much the same you do here in the extended transaction manager.

this.repository = repository;
}

@Cacheable(value = "configByName", key = "T(org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#propertyName)")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just in general: I would try to eliminate this service all together... as can be seen with this requirement to add caching... this thing is just getting in the way and it's not really dev-ops friendly (as you need a database in the first place to be able to do your configuration... instead of simple files)... just saying it again: I think reloadable configurations are a solved problem in Spring/Boot... my 2 cents here: this service is creating more head-aches than it provides solutions. But maybe a discussion for another day.

@Slf4j
@Service
@RequiredArgsConstructor
public class ConfigurationDomainServiceJpa implements ConfigurationDomainService {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

... see my comment on global configuration service... pretty much the same here.

return Arrays.asList(noCache, singleNodeCache);
}

public Map<String, Object> switchToCache(final boolean ehcacheEnabled, final CacheType toCacheType) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably I missed (a lot of) the conversation around this feature... but is there really a use case where you have to switch cache implementation during runtime? That seems to me such an important architectural decision that I would say it is done way before any instance of Fineract is running, at the least you would decide if EH Cache is enough or if you need it at all (I'd say the answer here is always yes... but not sure if you guys discussed a use case where no cache is desirable).
BTW: multi-node cache... Redis is your friend... 1st class support in Spring Boot and works really great (read: performant).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For multi node cache for defo we should use Redis

@vidakovic
vidakovic self-requested a review March 14, 2023 09:48

@adamsaghy adamsaghy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@ruchiD ruchiD left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@galovics
galovics merged commit e9e31a8 into apache:develop Mar 14, 2023
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 this pull request may close these issues.

4 participants