The best way to allow communication between two AEM instance is by:
- Exposing a service from the AEM instance which acts a source of information (say Source-AEM)
- Consuming the exported service in the required remote AEM (Consumer-AEM).
In case, you have a use-case where:
- A Service cannot be exposed via source AEM
- A utility needs to be deployed in Consumer-AEM to access Source-AEM’s information
Then, you can use the following steps to achieve the same.
Please note: AEM does not allow remote connection OOTB. Hence, we would be embedding jcr2dav bundles. No performance testing has been conducted for the shared code.
Step-1: Create a user in Source-AEM Instance.
Create a user in source-AEM Instance with bare minimum access needed by the utility.
Step-2: Add dependencies to your maven project
Add following dependencies to the maven project of the utility.
Since, the above bundles are not available in AEM, embed dependency for the above bundles in your pom.xml.
Step-3: Access source AEM instance from utlity.
Create an instance of “Jcr2davRepositoryFactory” to access the source AEM Instance.
For the sample code, access the servlet via URL (http://<Processor-AEM-HOST:Processor-AEM-port>/bin/testRemoteConnection), to get list of all components below “/apps/” folder on Source-AEM Instance.