Triggering a Workflow using Event Listeners in AEM

Triggering a Workflow using Event Listeners in AEM

AEM Version: 6.2
Target Audience: AEM Developers


In AEM 6.2 Workflows, we can trigger a workflow when a DAM Asset is created, modified, or deleted within a given path. In this article, we will explore triggering workflows from our code based on events in the JCR.

Suppose you have a workflow that creates custom renditions of assets in addition to the default AEM renditions, when the asset is under “/content/dam/ProjectName/images/”. You would have set up two launchers for triggering this workflow: one with event type as “Node Create” and one with “Node Modified”. We can also achieve the same functionality through our code, without touching the GUI.


When assets are moved into a certain folder structure in DAM, trigger a workflow that creates a 100px X 100px thumbnail of our image.


Fig 1: Before Moving the asset, no custom thumbnail. Fig 2: Desired result after moving the asset, the new thumbnail.


The intuitive thought is that when an asset is moved, a new node is created in the new location and the old one is deleted. However, experience shows that AEM does not create a new node in the destination folder on Node Move. We know this because the ‘jcr:Created’ property does not change. AEM does not even change the last modified date.

Creation Timestamp Before Moving the Asset Creation Timestamp is the same after moving

Fig 3: Creation Timestamp Before Moving the Asset. Fig 4: Creation Timestamp is the same after moving

Modification Timestamp Before Moving the Asset. Modification Timestamp is the same after moving

Fig 5: Modification Timestamp Before Moving the Asset. Fig 6: Modification Timestamp is the same after moving.

What if we copy the asset?

On copying the asset, a new version of the same is created. This triggers the Node Creation launcher.

No versions before copying the asset Version created after copy-pasting the asset

Fig. 7: No versions before copying the asset. Fig. 8: Version created after copy-pasting the asset.


Event Listeners

AEM supports observation, which enables us to receive notifications of persistent changes to the workspace. A persisted change to the workspace is represented by a set of one or more events. Each event reports a single simple change to the structure of the persistent workspace in terms of an item added, changed, moved or removed. There are thus 7 possible events at the JCR level, viz:

  1. Node Added
  2. Node Moved
  3. Node Modified
  4. Node Removed
  5. Property Added
  6. Property Removed
  7. Property Changed

We connect with the observation mechanism by registering an event listener with the workspace. An event listener is a class implementing the EventListener interface, that responds to the stream of events to which it has been subscribed. An event listener is added to a workspace with:

void ObservationManager. 
addEventListener(EventListener listener, 
int eventTypes, 
String absPath,
boolean isDeep, 
String[] uuid, 
String[] nodeTypeName, 
boolean noLocal)

(A detailed explanation of each parameter is given with the code example in the package as well as the at the end of this article) As defined by the EventListener interface, listener must provide an implementation of the onEvent method:

void EventListener.onEvent(EventIterator events)

When an event occurs that falls within the scope of the listener, the repository calls the onEvent method invoking our logic which processes/responds to the event. In our case, we will register an event listener to listen for “Node Moved” events under “/content/dam/images” so that when an asset is moved to that folder, our workflow can be triggered.


When the component is activated, the activate(…) method is called. It contains a call to ObservationManager.addEventListener(…) for registering the event listener. The deactivate(…) method contains logic for deregistering the event listener, and is triggered when the bundle is being stopped.

When the relevant event occurs, the onEvent(…) method is called, which contains logic for processing the event. In our case, we trigger a workflow.

The following is the relevant code from

protected void activate(ComponentContext ctx) { 

try { 
// Building the parameters for adding the event listener 

// Whether the subfolders of the given path should also be watched 

boolean isDeep = true; 

// Only events whose associated node has one of the UUIDs in this list will be 

// received. If this parameter is null then no UUID-related restriction is 

// placed on events received. 

String[] uuid = null; 

// Only events whose associated node has one of the node types (or a subtype of 

// one of the node types) in this list will be received. If this parameter is 

// null then no node type-related restriction is placed on events received. 

String[] nodeTypeName = null; 

// If noLocal is true, then events generated by the session through which the 

// listener was registered are ignored. Otherwise, they are not ignored. 

boolean noLocal = true; 

// Registering the event listener 

observationManager.addEventListener(this, Event.NODE_MOVED, ASSET_UPDATE_PATH, isDeep, uuid, nodeTypeName, 





public void onEvent(EventIterator itr) { 

while (itr.hasNext()) { 

Event currentEvent = itr.nextEvent(); 

try { 

// Create a workflow session 

WorkflowSession wfSession = workflowService.getWorkflowSession(localSession); 

// Get the workflow model 

WorkflowModel wfModel = wfSession.getModel(THUMBNAIL_WORKFLOW_PATH); 

// Get the Workflow data. The first parameter in the newWorkflowData method is 

// the payloadType. Just a fancy name to let it know what type of workflow it is 

// working with. 

WorkflowData wfData = wfSession.newWorkflowData(JCR_PATH, currentEvent.getPath()+ORIGINAL_RENDITION_RELATIVE_PATH); 

// Start the Workflow. 

wfSession.startWorkflow(wfModel, wfData); 


Download this code (including the workflow):

Build it using

mvn clean install -PautoInstallPackage

N.B: Creating a workflow is not part of this tutorial, and therefore a ready workflow has been provided in the code package. However, if you want to learn to create workflows, here is an excellent resource: ->


Adobe Consulting Services. (2018, March 20). acs-aem-samples/ at master · Adobe-Consulting-Services/acs-aem-samples. Retrieved from Github:

Day Software AG. (2018, March 20). JCR 2.0: 12 Observation (Content Repository for Java Technology API v2.0). Retrieved from Adobe Docs:

A Deeper Dive into Adobe Marketing Cloud

Adobe Marketing Cloud

Marketing professionals have to speak the language of their customers. In order to reach them, they have to deliver the right content through the right channels to the right devices and provide a personalized experience. To achieve this, marketers need to quantify facts with relevant data.

Your online presence must be consistent across devices, channels and languages to offer a connected experience. To achieve this, digital marketers need to efficiently manage and measure their social marketing activities and optimize their marketing expend on certain display.

So, is there an all-in-one digital marketing solution to help you crush your goals?

Fortunately, there is… the Adobe Marketing Cloud

Leveraging the eight solutions offered by Adobe Marketing Cloud, marketers can comfortably master their digital marketing problems.

Let’s explore more about each of these solutions.

Adobe Experience Manager

It is quite difficult to understand demands and meet the expectations of every single customer. They expect enterprises to provide relevant content on all devices. Also, they are constantly and quickly switching from one digital device to another. Whether they are shopping on your e-commerce website through their desktop, scrolling through your mobile app on their smartphones or visiting your store, they want all the digital experiences to seamlessly connect together.

So it’s important for brands to think about how to deliver consistent and continuous experience across all channels and devices. You have to enable your customer to continue where they left off even when they’re swapping between touchpoints.

Another important activity of marketers is managing several websites. This is quite a challenge because your website should adapt to multiple devices and languages.

If your assets aren’t well organised, the content will be inconsistent and irrelevant to the customer’s web experience.  You need an enterprise content management system that lets you easily optimize your websites and tie in your social platforms.

Enter the Savior, Adobe experience Manager!

Adobe Experience Manager helps you efficiently create, manage, deliver and optimize content and experience. This Adobe solution provides a web content management system featuring a multilingual what you see is what you get (WYSISYG) mode. With this powerful CMS, you can easily manage multiple websites, applications and digital publications.

AEM has 5 components:

  1. Sites
  2. Assets
  3. Apps
  4. Forms
  5. Communities

 Each of these have a critical role to play in making your brand journey delightful and building a comprehensive digital strategy.

Adobe Analytics

People visiting your site have different intentions. Some are there to buy stuff, some are simply researching products, and some might even be looking for a job. Then, you have your first-time visitors and returning visitors. Some segment of your visitors don’t know why they’re there in the first place and just want to get out.

Yet, most websites and landing pages display exactly the same content to all visitors – no matter what they’re searching for or how they got there in the first place. These websites try to appeal to a wide range of visitors simultaneously, and thus fail to really excite the potential buyers.

Wouldn’t it be awesome to display personalized content and call-to-actions for different types of visitors? Essentially making your visitors feel like the page speaks their language?

Well there is a grounded, leading solution named Adobe Analytics that provides digital marketers with one place to measure, analyze and optimize integrated data from all online initiatives across multiple marketing channels. 

It provides marketers with actionable, real-time web analytics intelligence about digital strategies and marketing initiatives.

It works by looking at the data which is provided by analytics about the visitor – things like location, keywords they searched for, ads they clicked, whether they’ve been to the site before and also data like buying history – and compares that against a set of variables that you have put in place. It lets you target relevant content to different types or groups of visitors based on their behavior or other variables.

Those variables could include:

  • Location – city, country, region
  • Device – iPhone, iPad, Android phone/tablet, Windows, Mac, Linux
  • Search keywords 
  • Visitor frequency – First, second, third, fifth time visitor?
  • Date and time of day, proximity to payday
  • Referring URL – where did they come from?
  • Customer history – have bought before, what they bought, how much did it cost?
  • Sessions behavior – navigation clicks, page views

There are many more variables which can be taken into account like age, gender, etc. The possibilities are pretty much endless and it depends a lot on how much info you already have about your customer.

Adobe Target

In this competitive era of digital marketing, every visitor on your website can never be a customer. Every marketing professional wants to communicate well with their visitors by extracting their needs and personalized interest. Every customer expects a unique experience and personalized offers rather than a one-sided or automated communication from a website. In order to fulfil those expectations, a marketer requires an effective plan to get an optimum amount of marketing expenditure so as to offer a limited number of discount on stuff. 

Adobe Target analyzes customer wishes and demands through the data generated by Adobe Analytics. This helps to deliver relevant content and tightly integrate with Adobe Social for enhanced social marketing. Now you can deliver the ads or promotions of the right products to the right targeted customers. This kind of automated behavioral targeting imparts an exponential growth in number of customers.

Also it helps to dynamically create content based on the visitor’s profile and to suggest targeted recommendations to the user even before they finish typing out their search queries. External data sources like order history can also be integrated to analyze visitor profile which further helps in optimized merchandising and offering discount on the targeted stuff. This dynamic navigation guarantees a perfect on-site experience.

Adobe Campaign

It is very important to reach out to your customers in meaningful ways.

With Adobe Campaign you are able to integrate and deliver one-to-one campaign so all the customers get relevant and consistent experience across online and offline channels.

We understand each customer through their integrated profile, which is made up of the purchasing history, social interactions, their location and other information gathered by Analytics and pulled into Adobe Campaign.

Adobe Campaign uses this analytics data to create personalized campaigns according to the customers interest.

Reports in adobe campaign show you how things are going, you can see who is responding to your offers, how much revenue your campaigns is generating.

With adobe campaign you have a deep real time understanding of your customers so you can design, integrate and automate cross channel experiences and measure the success. All for one solution.

Adobe Social

Social media managers are responsible for increasing brand reach and audience engagement through social platforms and creating a consistent brand experience across channels and devices.

They must also ensure the right message gets through all the noise of social traffic to the right customers and you need to respond to customer issues that arise via social platforms. All the while you must also connect all these social efforts to measurable business results.

How can one possibly monitor, manage and measure so many social media channels and also quantify the business value of social marketing?

Easy! All you need is Adobe Social.

Adobe social enables marketers to scale social activities across the organization; create and deliver relevant, engaging content across all social properties; capture and analyze all key sources of meaningful social data alongside integrated conversion metrics; leverage data to demonstrate social value and optimize interactions; and manage and strengthen customer relationships across social channels – all from one integrated platform.

Adobe Audience Manager

What problems are we trying to solve with Audience Manager?

Marketers have multiple database and technologies that they use to solve personalization across each channels.

There are lot of technologies, and customers can be on web, mobile, email or social. The challenge here is that the database touches into multiple channels. Marketers here really didn’t have a coherent or a relevant conversation as a consumer moves across multiple touchpoints. And this is the reason for disjoint experiences. 

And this is something that can be address by a Data Management Platform (DMP).

A DMP or Audience Manager (in the case of Adobe) consolidates audience information from all available sources. It identifies, quantifies and optimizes high value target audiences which can then be offered to advertisers via an integrated, secure, privacy-friendly management system that works across all advertising distribution platforms.

 DMP comprises 4 key parts:

  1. Collect Data – Collect data and allow it to sit in a single repository.
  2. Unify Data to a profile – DMP can take this data from the different sources and tie that data back to a profile.
  3. Create Audiences – In DMP, you can take the various profile information that you need to create audiences and audience segments.
  4. Push to Marketing platforms: Value you create through these segments is the capability to reach the people who follow the segments.
Adobe Media Optimiser

Once building a great website is done, it is time think about the MOOLAH!

Marketers really need to get a larger return on their ad spend to engage more relevant audiences, derive brand awareness and generate revenue.

But how should one distribute their media budget between display, search and social?

What is the most profitable way to run a cross-channel advertising campaign?

Advertisers are trying to simplify their lives, they are trying to have more control over right campaigns and their budgets and trying to be more efficient with their ad buys.

With Adobe Media Optimiser, we can answer all these questions easily and get maximum return on investments.

Using mathematical models and industry leading algorithm, Adobe Media Optimiser evaluates the situation which enables you to adjust your strategies, goals and budget in real time.

It also provides precise forecast based on our goals and predicts the best channels mix for his budget.

With Adobe Optimiser, marketers can manages all of their campaigns for every platform. Search engines like Google & Bing. Social platforms like Facebook and Twitter.

So, marketers can always rely on peak conversions and the right investments.

The right messages to right people at the right time

Finally, not only traffic on websites will increase but the revenue will also grow profitably.

Adobe Primetime

The way people watch TV and video has evolved. 

You need to personalize and then individualize the viewing experience constantly.

Users want to jump in and enjoy shows only when you offer them a fully immersive experience. This means making it easy for each viewer to securely stream their desired TV shows, sports programs and films in high definition across different screens wherever and whenever they want to.

Adobe Primetime, part of the Adobe Marketing Cloud, helps deliver engaging experiences for viewers to amass more subscribers and revenue from advertising and subscription.

Now it’s possible to create engaging experiences on every device using Primetime.

Primetime allows you to deliver the right ads to the right audience to improve the effectiveness of your ad sells.


We all know that the key to mastering customer experience (CX) is knowing the customer and for this Adobe Marketing cloud is the perfect fit. My vote goes for Adobe Marketing cloud.

What about you?

Credits: Adobe Sites

Decoding the Magical Marketing Mechanism with Adobe Marketing Cloud

the logos of the solutions in the adobe marketing cloud suite such as Adobe Social, Adobe Experience Manager and Adobe Analytics

You’re munching on your favorite hot and crispy samosa while checking your emails on your mobile. You receive a marketing email from your favorite e-commerce site about the pair of designer jeans you have been looking to buy. The email says it is now available at a steep discount. You were following this jeans on the web and social media for quite some time and always wished you get some discount on it. You had seen ads of it in your social networking and media sites, and always thought of owning it. You had in fact added it into your shopping cart but always felt it to be expensive.

You click the link in the email and see some attractive photos of it along with other interesting suggestions based on your interest.

Excited, you call your best friend and tell the same but she hasn’t received any such email or seen any reduction in price or discounts on the site.

You think of buying it immediately as you don’t want to lose the opportunity or risk the out-of-stock scenario.

You go ahead and buy it immediately with your credit card. WOW! That’s the exhilarating feeling you get. You are doubly excited about this purchase because you’re going to wear it to the weekend party. You feel thankful to the e-commerce site for making you feel special by offering the discounted price only to you. You also pat yourself on the back for your excellent decision to purchase. You quickly share and tweet about your purchase and your friends are liking it.


  • How did your favorite e-commerce site know you were looking for “jeans” from quite some time now?
  • How could only you get the email and the discounts?
  • How could you see more suggestions and options which you had tried searching but could not get?

Adobe Marketing Cloud is an all-in-one digital marketing solution which can help answer the above questions.

the logos of the solutions in the adobe marketing cloud suite such as Adobe Social, Adobe Experience Manager and Adobe Analytics

Let’s suppose, the e-commerce site was using the Adobe Marketing Cloud to achieve this. Here is how they could have used different tools available in the suite.

  • Adobe Audience Manager consolidates audience information from all available sources and create profiles of audience segments to send the email only to you.
  • Adobe Campaign used analysis done by Adobe Social and Audience Manager to send you the personalized email. Adobe  Target and Personalization provided you with more suggestions and compelling offers and options.
  • You shared your purchase through social sites and the e-commerce site could do more promotions based on the links and shares. They could get more people to know about the purchase and could listen to the social activities using Adobe Social.
  • A nice looking website with captivating graphics, content along with the personalized options were hosted on Adobe Experience Manager.
  • Adobe Media Optimizer helps the e-commerce site to get maximum return on their investments.

Why did the e-commerce site offer an expensive pair of jeans at a discounted price? Only to you?

  1. The e-commerce site benefited by acquiring a customer (you) and providing a compelling digital experience. This can go a long way in retaining the customer.
  2. It helped convert a potential customer to a buyer and also received healthy promotion and follow on social networking sites, which engaged new users and converted existing users into loyal customers.
  3. It is very important to not just reach the right customers but understand them well. Adobe Marketing Cloud solutions help you do this effortlessly and quickly to get your campaign rolling in record time.

Adobe Marketing Cloud is a comprehensive digital marketing solution. It enables marketers to measure, personalize and optimize marketing campaigns and digital experiences for optimal marketing performance. Adobe Marketing Cloud includes a set of analytics, social, advertising, media optimization, targeting, web experience management and content management tools for effective digital marketing.

 It is one of the most comprehensive and integrated digital marketing solution for digital marketers.

 Adobe Marketing Cloud solution consists of –

  1. Adobe Analytics
  2. Adobe Audience Manger
  3. Adobe Campaign
  4. Adobe Experience Manger
  5. Adobe Media Optimiser
  6. Adobe Primetime
  7. Adobe Social
  8. Adobe Target


Explore each of these solutions in the Adobe Marketing Cloud in detail in this article.

The Performance Guidepost

The Performance Guidepost

Imagine on a bright sunny day you open up your analytics dashboard and you notice the visitors graph going high and high and high and suddenly drops all of a sudden.

You will be wondering what is happening, only to find that your colleague had started a nice promotion and due to the promotion the website load increased multifold.

But what happened all of a sudden? Why the drop in visits? Ah… the promotion became too popular as it had gone viral in the social network and print media. And due to the heavy demand more number of users visited and the site could not take up the anticipated load and crashed.

A poor show, in spite the excellent job by marketing team.

What could have been done to avoid such situation and do not let the customer suffer and the drop in sales and site visitors?

Performance testing is the answer on anticipated site load.


[av_heading heading=’What is Performance Testing?’ tag=’h3′ style=” size=” subheading_active=” subheading_size=’15’ padding=’10’ color=” custom_font=”][/av_heading]

Triple “S” check is a must for the public facing websites.

  • Speed – Determines whether the application responds quickly.
  • Scalability – Determines maximum user load the software application can handle.
  • Stability – Determines if the application is stable under varying loads.

And all three can be measured using performance testing.

Performance testing is the investigation done either to determine or to prove the response time, scalability and performance of the website to ensure that they will perform well under their expected regular workload, at peak load and uncover inconsistencies across different operating systems/devices.

The goal of performance testing is not to find bugs but to eliminate performance bottlenecks and tune the system for maximum load. This is also to determine the maximum threshold the website can take.

[av_heading heading=’Common Performance Problems’ tag=’h3′ style=” size=” subheading_active=” subheading_size=’15’ padding=’10’ color=” custom_font=”][/av_heading]

Poor Response Time:

Once the user performs an action and user has to wait for so long before the response is provided. This can lead to poor user experience.

Poor Load Distribution:

Poor load distribution can cause slow response time by incorrectly assigning new site visitors to hanged up servers. If too many people are on the same server, they’re going to experience difficulties, even if the overall system is well under capacity. Check the sites of some of the big players and you will notice the site loads in a flash of moments.

[av_heading heading=’Types of Performance Testing’ tag=’h3′ style=” size=” subheading_active=” subheading_size=’15’ padding=’10’ color=” custom_font=”][/av_heading]

Load Test:

Generally a load test is conducted to understand the behaviour of a system under the specific expected load. It helps to identify the maximum operating capacity of an application as well as any bottlenecks and determine which element is causing degradation. E.g. If the number of users are increased then how much CPU, memory will be consumed, what is the network and bandwidth response time.

It also helps in measuring the response time, throughput rates, and resource-utilization levels, and to identify the breaking point, and the peak load the website can handle.

This can answer questions like, what is the maximum number of users that can use the system without any impact on performance and acceptable response time.

Stress Test:

Stress testing refers to the testing of website to determine whether its performance is satisfactory under any extreme and unfavourable conditions, which may occur as a result of heavy network traffic, process loading and maximum requests for resource utilization. Stress testing enables to identify how the website behaves under extreme load conditions.

This will answer questions like, what is the maximum peak load the system can handle and determine if the system will perform sufficiently if the current load goes well above the expected maximum limits.

Soak / Endurance Test:

This is usually done to determine if the system can sustain the continuous expected load, this helps in detecting potential memory leaks and utilization. Also to check the performance degradation when the system is being used for long duration.

This can answer questions like, if the promotion becomes very popular and the load of system is way beyond for a very long duration, can the system handle such situations?

Spike Test:

Spike testing is a subset of stress testing.  A spike test is a type of performance test focused on determining reaction to a sudden large spikes in the load generated by users.

This can answer questions like, if the competitor, runs a promotion and we are unaware of it, due to such situations users visiting the site for similar promotions on our site, there could be sudden spike of users and if the system can handle such situations.

[av_heading heading=’Tools’ tag=’h3′ style=” size=” subheading_active=” subheading_size=’15’ padding=’10’ color=” custom_font=”][/av_heading]

Lot of performance testing tools are available for different types of tests and it is quite difficult to cover all types of test using one.

Jmeter is one of the renowned open source tool designed to load test functional behaviour and measure performance.

Lets explore more about Jmeter and its functioning in the upcoming blog.

[av_heading heading=’Conclusion’ tag=’h3′ style=” size=” subheading_active=” subheading_size=’15’ padding=’10’ color=” custom_font=”][/av_heading]

Performance Testing is a must before the website goes to market, as poor performance and inconsistent behaviour of the site may lead to inadequate reputation, poor user experience and will not meet the sales goals.

Hence its concluded that it’s a must to perform performance testing at initial stage of building website and regularly in different intervals. Analytics can help monitor the peak loads and help plan for performance testing. This can go a long way building customer trust, relation and not only retain but expand customer base. Lets read about that too in another upcoming blog.