'AEM Configuration
Configurations are applied to an AEM instance based on run modes. How AEM determines the config file to be picked in case of multiple runmodes and multiple configurations?
Assuming the below configs are available in an AEM project,
/apps
/myproject
- config
- config.prod
- config.author
- config.active
- config.prod.active
- config.prod.author.active
which configuration gets picked or applied to an AEM instance created with run modes author,nosamplecontent,prod,active?
Is there any defined set of rules(or best practices) related to config creation documented that i can refer while setting up the project
Thanks,
Jai
Solution 1:[1]
This article talks about the specifics of how they are applied: https://helpx.adobe.com/experience-manager/6-4/sites/deploying/using/configuring-osgi.html?cq_ck=1368002864971#ConfigurationDetails
Resolution of multiple Run Modes
For run mode specific configurations, multiple run modes can be combined. For example, you can create configuration folders in the following style:
/apps/*/config../
Configurations in such folders will be applied if all run modes match a run mode defined at startup.
For example, if an instance was started with the run modes author,dev,emea, configuration nodes in /apps//config.emea, /apps//config.author.dev/ and /apps//config.author.emea.dev/ will be applied, while configuration nodes in /apps//config.author.asean/ and /config/author.dev.emea.noldap/ will not be applied.
If multiple configurations for the same PID are applicable, the configuration with the highest number of matching run modes is applied.
For example, if an instance was started with the run modes author,dev,emea, and both /apps//config.author/ and /apps//config.emea.author/ define a configuration for com.day.cq.wcm.core.impl.VersionManagerImpl, the configuration in/apps/*/config.emea.author/ will be applied.
This rule's granularity is at a PID level. You cannot define some properties for the same PID in/apps//config.author/ and more specific ones in /apps//config.emea.author/ for the same PID. The configuration with the highest number of matching run modes will be effective for the entier PID.
Here are some best practices:
Solution 2:[2]
I think, when you create a aem instance using java -jar command, you can mention the run mode of aem instance prod, stage, author, publish etc.
This is what mapped to apps/myproject - config.* folder names.
Solution 3:[3]
configurations are picked up top to low . i.e. .prod will get applied to all prod instances and superseded by one level prod.active. ... once configuration are created, instances running need to have run modes added to it accordingly.
Solution 4:[4]
Configurations in such folders will be applied if all run modes match a run mode defined at startup.
As per your example, if an instance was started with the run modes author,nosamplecontent,prod,active
/apps
/myproject
- config ---> will be applied
- config.prod ---> will be applied
- config.author ----> will be applied
- config.active ----> will be applied
- config.prod.active ----> will be applied
- config.prod.author.active ---> will be applied
Configurations that you provide in these folders generally are for specific PID. If multiple configurations for the same PID are applicable, the configuration with the highest number of matching run modes is applied.
So for e.g. if you had configuration for resourceresolver in config.prod as well as config.prod.active (but not in any other folder) then configuration for the resource resolver will be active from config.prod.active since that matches the higher number of runmodes applied.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Shawn |
Solution 2 | Sri |
Solution 3 | SA007 |
Solution 4 | mihir |