Closed ranishwetha closed 5 years ago
Hi, any update or observation on this?
Hi @ranishwetha -
Alright, where to begin?
1) First, you state...
In my application, I don't need client cache either. Is there a way to avoid using this?
What do you mean by, "I do not need a ClientCache
?"
Why would you use Spring Boot for Pivotal GemFire (SBDG) in the first place if you did not need a ClientCache
(?), where it would seem you are deploying your Spring Boot app to PCF and using PCC (??). In order to connect to a PCC cluster in PCF, you need a ClientCache
instance. If you have defined GemFire objects (e.g. Regions) in your application configuration to manage your data, then those objects require a cache instance.
It would also seem your are using PCC as a "caching provider" / backing store for the implied use of Spring's Cache Abstraction in your application given the declaration of the @EnableGemfireCaching
annotation.
Given the above, this is why you getting the follow error message by Spring Boot on startup:
Consider defining a bean named 'gemfireCache' in your configuration
2) Second, when using Spring Boot for Pivotal GemFire (SBDG), you do not need to "explicitly" annotate your application configuration class (i.e. GemFireConfiguration
) with any of: @ClientCacheApplication
, @EnableGemfireCaching
, @EnablePdx
nor @EnableSecurity
since, OOTB, SBDG provides auto-configuration for all of these features.
SBDG provides you with a ClientCache
instance, by default. It also enables PDX, by default. It can detect the context in which your app is deployed/running (e.g. PCF when using PCC) and automatically apply the necessary/required Security settings, by default. And, when either Apache Geode or Pivotal GemFire is on your application's classpath, then SBDG will automatically use GemFire or Geode as a "caching provider" in Spring's Cache Abstraction, by default.
You typically do not declare any of the SDG's 3 cache type annotations [@ClientCacheApplication
, @PeerCacheApplication
, @CacheServerApplication
] when using SBDG unless you want to A) override the cache type (again, a ClientCache
by default) to use another type of cache (e.g. a "peer" cache instance when you want your application to be "peer" member of the GemFire/PCC cluster, which is rare) or B) you want to supply custom, very-specific cache configuration (e.g. subscriptionEnabled = true
on the client).
Of course, there are other ways to accomplish the later (B), i.e. supplying additional, custom cache configuration, either by way of Properties or using a Configurer bean.
To get these "default" features out of the box, you simply only need to declare org.springframework.geode:spring-gemfire-starter
in your application dependencies, thereby adding the LIB to your application's classpath at runtime.
3) Third, you do not need to specifically annotate your application configuration class with @Configuration
either, since the @ClientCacheApplication
annotation, or even Spring Boot's @SpringBootApplication
annotation is already (indirectly) meta-annotated with @Configuration
. For instance.
The only annotations you need in your case to get started, really, is...
@SpringBootApplication
class MySpringBootApplication { .. }
... again, providing the org.springframework.geode:spring-gemfire-starter
dependency (LIB) is on your application's classpath at runtime.
Done!
4) Finally, as for logging...
Neither the @ClientCacheApplication
annotation, nor SDG in general, prevent you from customizing the logging for a GemFire client or server itself.
Under the hood, Pivotal GemFire/PCC (and by extension, Apache Geode) uses the Log4j framework as its logging facade and implementation. Therefore, you can supply the logging configuration for a GemFire/PCC app by following the documentation.
The @ClientCacheApplication
annotation simply gives you the ability to affect the logLevel
.
And, since you do not explicitly need to specify the @ClientCacheApplication
annotation in a SBDG application, and thus have no direct way to set logLevel
by way of the @ClientCacheApplication
annotation logLevel
attribute, SDG provides the @EnableLogging
annotation, which implies this setup.
Either way, it seems in your case, you should be following the "advice" in the opening paragraphs, here.
Hope this helps!
Regards, @jxblum
Thanks John! This is helpful.
@ClientCacheApplication
overrides my logger settings. None of my log4j information is carried since I have declared this.In my application, I don't need client cache either. Is there a way to avoid using this? Kindly advise?
If I comment on this line I get below error -
Consider defining a bean named 'gemfireCache' in your configuration
Changes made:
Log shows the override. Please let me know if how I can avoid it.