How to invoke any servlet at publish instance in workflow step ? | Community
Skip to main content
Suraj_Kamdi
New Participant
Jan 29, 2019 12:20 PM UTC

How to invoke any servlet at publish instance in workflow step ?

I want to invoke the custom servlet to perform some action in publish server through custom workflow step. Anyone has idea how to achieve this scenario ?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

5 replies

mvip
New Participant
Jan 29, 2019 10:25 PM UTC

You can use HttpClient.

Refer below URL:

https://helpx.adobe.com/experience-manager/using/HttpClient_AEM.html

Translate
smacdonald2008
Level 10
Jan 29, 2019 1:39 PM UTC

Yes - but why not implement a service (as opposed to a Servlet) then you can use @Reference annotation from within your custom step to invoke the Java logic.

Translate
Suraj_Kamdi
New Participant
Jan 29, 2019 1:44 PM UTC

as per the acceptance criteria i have to invoke servlet from custom workflow step. Currently i am using CloseableHttpClient closeableHttpClient to invoke servlet.

Translate
Gaurav-Behl
Level 10
Jan 29, 2019 3:31 PM UTC

Based on your project's design and requirements whatever you choose to use (either servlet or service or just a component), the underlying logic would primarily work in same manner -  Get hold of server's runmode and process your custom code.

To get the run mode in server side code -

Slice-CQ/WcmModeModel.java at master · Cognifide/Slice-CQ · GitHub

or use

final WCMMode mode = WCMMode.fromRequest(request);

if (null == mode || WCMMode.DISABLED.equals(mode)) { // do something }

*you would find WCMMode in uber-jar

Create your workflow, register it and use WCMMode to excute it only on publish server. Once everything is done, configure this workflow step in your custom workflow.

Example -

Adobe Experience Manager Help | Invoking Adobe Experience Manager Workflows using the AEM Java API

Hope that helps.

Translate