Expand my Community achievements bar.

SOLVED

How to make a call a scheduler form another scheduler which is present in another publisher which needs to be activated after the completion of service in 1 st publisher

Avatar

Level 1
 
1 Accepted Solution

Avatar

Correct answer by
Employee

This is not possible in a reliable way just by AEM ootb tools.

  • You would need an external system, e.g. a message queue to handle the message passing. Direct connection is probably not reliable enough, as the publishs can be down at any time (and this is not limited to AEM as a Cloud Service, where restarts on a publish level probably happen more frequent than in AMS or on-prem setups).
  • You need to designate publishs with that role. I am not sure if that's a sensible way to do...

 

What business requirement are you trying to solve?

View solution in original post

6 Replies

Avatar

Community Advisor

@Prakul 

 

Just curious, why are we executing the schedulars in sequence?


Aanchal Sikka

Avatar

Level 1

@aanchal-sikka 

 

I need to call same scheduler which is present in different publisher but the call should be in serial order

Avatar

Community Advisor

@Prakul 

 

Not sure about the your actual requirement, but if you need to execute the scheduler in 2 or more publishers in a serial manner, then you may calculate the time it is taking to finish this scheduler job and set the scheduler cron job on Publish 1 and Publish 2 accordingly.

For Example: If the job is taking 15 mins to finish, the set the cron expression to run the job at 12.00am on publish 1 and then 12.15 on publish 2.

Avatar

Community Advisor

Hello @Prakul -

 

Here is a solution which I can think of on a high level reading through your requirements : 

 

In AEM as a Cloud Service, you can achieve the inter-scheduler communication and activation by utilizing the Sling Job Queue and Eventing mechanisms. Here's an outline of the approach:

 

1. Define the first scheduler in the first publisher:
- Create a Sling Job Queue by extending `JobConsumer` and implementing the desired service logic.

 

2. Implement the service in the first publisher:
- Write the code for the service that needs to be executed by the first scheduler.
- Ensure that the service logic is completed before proceeding to the next step.

 

3. Configure the second scheduler in the second publisher:
- Create another Sling Job Queue following the same approach as the first scheduler.
- Define the logic that needs to be executed by the second scheduler upon activation.

 

4. Establish communication between the publishers:
- Use the Sling Eventing mechanism to trigger an event from the first publisher after the service logic within is completed.
- Configure an Event Handler in the second publisher to listen for this event.

 

5. Trigger the second scheduler from the first publisher:
- After the service in the first publisher completes, use the Sling Eventing mechanism to publish an event.

 

6. Activate the second scheduler in the second publisher:
- The Event Handler in the second publisher listens for the event published in the first publisher.
- Upon receiving the event, the handler can activate the second scheduler, and the associated logic will be executed.

Avatar

Community Advisor

Hello @Prakul Based on your requirement, it seems that you need to establish a sequential connection between a scheduler in Pub1 and Pub2. Presumably, these schedulers have specific tasks to perform.

 

Here's my suggestion: utilize a single scheduler alongside an OSGi service. The scheduler will be set to execute at a specific time from Pub1, and upon execution, it will call the OSGi service. To introduce time delays between the calls, you can incorporate appropriate logic within your Java implementation. In my opinion, this solution offers a more efficient approach. If you have the authority to make decisions in your project, I recommend proposing this solution.

 

Thank you,

-Bilal

Avatar

Correct answer by
Employee

This is not possible in a reliable way just by AEM ootb tools.

  • You would need an external system, e.g. a message queue to handle the message passing. Direct connection is probably not reliable enough, as the publishs can be down at any time (and this is not limited to AEM as a Cloud Service, where restarts on a publish level probably happen more frequent than in AMS or on-prem setups).
  • You need to designate publishs with that role. I am not sure if that's a sensible way to do...

 

What business requirement are you trying to solve?