<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kelvin Xu on Medium]]></title>
        <description><![CDATA[Stories by Kelvin Xu on Medium]]></description>
        <link>https://medium.com/@kelvinxu88?source=rss-c1d307980e2f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*s4dWwy9-DZ7iShHUtJ9WjQ.jpeg</url>
            <title>Stories by Kelvin Xu on Medium</title>
            <link>https://medium.com/@kelvinxu88?source=rss-c1d307980e2f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 01:07:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kelvinxu88/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Firefly Services API: Strategies & Best Practices Every Developer Should Know]]></title>
            <link>https://medium.com/adobetech/firefly-services-api-strategies-best-practices-every-developer-should-know-42d8b74a226d?source=rss-c1d307980e2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/42d8b74a226d</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[adobe-firefly]]></category>
            <category><![CDATA[platform]]></category>
            <category><![CDATA[api-strategy]]></category>
            <category><![CDATA[generative-ai]]></category>
            <dc:creator><![CDATA[Kelvin Xu]]></dc:creator>
            <pubDate>Mon, 19 Aug 2024 20:02:38 GMT</pubDate>
            <atom:updated>2024-08-19T20:02:38.469Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Strategies &amp; Best Practices Every </strong>Firefly Services API <strong>Developer Should Know</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NngEnPJDqTxjnv4jxIsouA.jpeg" /></figure><p>Adobe <a href="https://developer.adobe.com/firefly-services/docs/guides/">Firefly Services</a> offers a comprehensive set of generative AI and creative APIs that can enhance enterprise processes and workflows. The services include APIs such as Firefly APIs, Photoshop APIs, Lightroom APIs, and Content Tagging APIs. These APIs, having evolved from different backgrounds and timelines, exhibit some differences in API signatures, input/output formats, and response behaviors. It’s crucial to understand these nuances and adopt key strategies and best practices that can guide developers in using these APIs effectively.</p><h3><strong>Authentication</strong></h3><p>Authentication is the foremost step before making any valid API request. Licensed customers can follow the guide <a href="https://developer.adobe.com/firefly-services/docs/guides/get-started/">here</a> to obtain the client ID and client secret, then use a curl command to acquire the access token. This process is fairly straightforward, but it’s important to note that this is a <a href="https://developer.adobe.com/developer-console/docs/guides/authentication/ServerToServerAuthentication/">server-to-server authentication</a> mechanism, meaning that it does not involve your application’s end users logging in. The authentication occurs solely between your application and Firefly Services, so it’s essential to implement it securely.</p><p>For example, in web application development, developers must avoid obtaining the access token from the client side, as this could easily expose credentials. The access token should be fetched on the server side to ensure that credentials remain secure.</p><p>When implementing this in practice, consider using a common library or method to generate the token centrally. If you’re using Node.js, you can leverage <a href="https://github.com/adobe/aio-lib-ims">this library</a>. Since the token is valid for 24 hours, it’s wise to cache it (e.g. with a TTL of 23 hours and 55 minutes) and reuse it rather than fetching a new token every time.</p><h3><strong>Storage for inputs &amp; outputs</strong></h3><p>Both Photoshop (including Lightroom) and Firefly APIs generally require <a href="https://developer.adobe.com/firefly-services/docs/photoshop/general-workflow/#input-and-output-file-storage">input and output images</a> to be served from cloud storage or pre-signed URLs. These APIs currently support S3, Azure Blob Storage, and Dropbox. For Photoshop APIs, a resource served from a pre-signed URL is required to start any API operation. Firefly, however, provides an <a href="https://developer.adobe.com/firefly-services/docs/firefly-api/guides/api/upload_image/">upload endpoint</a> for temporarily storing source files if no cloud storage is available. This upload endpoint returns an upload ID rather than a pre-signed URL, which means it cannot be reused in Photoshop (and Lightroom) APIs. Therefore, if your implementation involves orchestration across Firefly and Photoshop APIs, it’s advisable to have cloud storage ready from the start.</p><h3><strong>Sync vs. a-sync</strong></h3><p>As of now, Firefly APIs are synchronous, meaning that after making a request, you will receive the results (either success with output images or failure with an error message) in the response within a few seconds. This real-time generation does require some computational time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*cRwJSKB18L44658arbmK8g.png" /></figure><p>On the other hand, Photoshop APIs are asynchronous. After making a request, you will immediately receive a job ID rather than the actual outputs. You will then need to <a href="https://developer.adobe.com/firefly-services/docs/photoshop/code-sample/#fetch-the-status-of-an-api">poll the job status</a> using the job ID until you receive the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*yD0fVLFOENK1LQXOj4ckVg.png" /></figure><p>Understanding these API characteristics will help you design and develop your applications more effectively (Ideally, both APIs should support both synchronous and asynchronous operations, or at least offer a choice).</p><p>For real-time generation apps using Firefly APIs, you may need to set up appropriate expectations upfront, perhaps by using a loading spinner or skeleton loader on the UI side. For Photoshop APIs, asynchronous processing is excellent for parallel processing at scale. However, for real-time user interactions, you might need to “convert” the asynchronous behavior to synchronous by introducing status polling until completion, or by using the <a href="https://github.com/Firefly-Services/firefly-services-sdk-js/blob/main/examples/javascript/photoshop/photoshop.js#L70">Firefly SDK</a>, which encapsulates the polling process for you.</p><p>For scalable parallel processing, you also can leverage eventing. Photoshop supports eventing through Adobe’s serverless platform, <a href="https://developer.adobe.com/firefly-services/docs/photoshop/features/#webhooks-through-adobe-io-events">Adobe IO Events</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*6PsRqNoDAnjqp7vuVDindw.png" /></figure><p>In this model, the client doesn’t need to poll the status continuously, as a job completion event will be emitted to IO Events, to which a webhook or IO runtime action can subscribe. This approach allows the client to be more performant and is ideal for implementing bulk processing (the webhook or IO runtime action running in Adobe IO platform is <a href="https://blog.developer.adobe.com/adobe-app-builder-the-power-of-scaling-at-your-fingertips-8ae1149b7ebd">autoscaled</a>).</p><h3><strong>Rate limiting</strong></h3><p>By default, Firefly APIs have a <a href="https://developer.adobe.com/firefly-services/docs/firefly-api/guides/concepts/rate-limits/">rate limit</a> of 4 RPM (requests per minute) and 9,000 RPD (requests per day). Licensed customers can request higher limits based on their annual quota and estimated traffic. However, despite the best estimations, hitting the rate limit might be inevitable during unexpected traffic spikes, or a large campaign event.</p><p>A common strategy is to implement a retry logic. If you encounter a 429 response code, you can retry after waiting for the “retry-after” period indicated in the response header or implement an <a href="https://docs.aws.amazon.com/prescriptive-guidance/latest/cloud-design-patterns/retry-backoff.html">exponential backoff pattern</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*-aJuvu-0rE2S-kHoq7RrhQ.png" /></figure><p>Another strategy to avoid hitting the rate limit is pre-generation (in the case of text2image). The enterprises wanting to enforce brand consistency in generated images should also consider this strategy. The process can be split into pre-generation and delivery phases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*m5io5aWZy6W5SkL3PDsVXw.png" /></figure><p>During the pre-generation phase, enterprises can use predefined prompt templates to generate large number of images that maintain brand consistency (techniques including style/structure referencing or customer models, etc.). This can be done over an extended period, respecting the rate limit, and storing the generated images in a database or cloud storage with search and query capabilities. Metadata and tagging can also be generated (i.e. using <a href="https://experienceleague.adobe.com/en/docs/experience-platform/intelligent-services/content-commerce-ai/overview">Content Tagging API</a> or GPT Vision) to assist in indexing.</p><p>On the delivery side, client apps can guide users to turn their inputs into image queries against the stored images. These pre-generated images can be delivered directly or used to generate more personalized experiences based on user inputs. Since the images are pre-generated, quality and brand consistency can be ensured, real-time inference is avoided (cost effective), and hitting the rate limit is mitigated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42d8b74a226d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adobetech/firefly-services-api-strategies-best-practices-every-developer-should-know-42d8b74a226d">Firefly Services API: Strategies &amp; Best Practices Every Developer Should Know</a> was originally published in <a href="https://medium.com/adobetech">Adobe Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[App Builder Code Deployment Strategies that AEM Developers Should Know]]></title>
            <link>https://medium.com/adobetech/app-builder-code-deployment-strategies-that-aem-developers-should-know-a9c677cbfe5d?source=rss-c1d307980e2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9c677cbfe5d</guid>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[app-builder]]></category>
            <category><![CDATA[platform]]></category>
            <category><![CDATA[aem-developer]]></category>
            <category><![CDATA[adobe-io]]></category>
            <dc:creator><![CDATA[Kelvin Xu]]></dc:creator>
            <pubDate>Wed, 07 Jun 2023 21:33:26 GMT</pubDate>
            <atom:updated>2023-07-10T21:32:41.395Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>With Adobe Experience Manager (AEM) now available as a Cloud Service, here are a few approaches that AEM developers can use to make the most of its App Builder framework.</em></h4><p>The introduction of Adobe Experience Manager (AEM) as a Cloud Service gives users the benefits of increased scalability and high availability.</p><p>To make this possible, AEM’s code deployment strategy and technology have moved to Cloud-Manager-based pipelines that can provide more reliable and streamlined deployment experiences.</p><p>When it comes to cloud-based integrations between AEM and external applications, Adobe Developer App Builder is the recommended framework. App Builder can empower AEM developers to leverage Adobe’s serverless platform to achieve various integration objectives.</p><p>However, AEM and App Builder are totally different systems, which means it is essential for AEM developers to understand how App Builder code should be deployed in terms of strategies and techniques.</p><p>So let’s get started.</p><p>First, let’s take a look at the <a href="https://github.com/adobe/aio-cli">aio CLI</a> based approach:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/0*THE3PeJhngUMExXC" /></figure><p>In App Builder, “workspace” is a similar term to “environment”.</p><p>Suppose you are implementing integrations for AEM with App Builder and matching with AEM environments, like Dev to Prod.</p><p>In that case, you can create additional workspaces during <a href="https://developer.adobe.com/app-builder/docs/getting_started/first_app/#2-creating-a-new-project-on-developer-console">App Builder project creation</a> (Stage and Prod are the default ones). Then you can <a href="https://developer.adobe.com/app-builder/docs/getting_started/first_app/#4-bootstrapping-new-app-using-the-cli">bootstrap the App Builder code</a> with aio app init and just run aio app deploy to deploy the code to the current project and workspace you are in.</p><p>There are a couple of key things to bear in mind here to ensure this approach works properly.</p><p>One is the (current) project/workspace to which the code is being deployed. This depends on your login state, and you can use aio where to check your current org, project and workspace. If this is not where you want to deploy the code, you can use aio app use to switch (the command will prompt you with instructions).</p><p>The second thing is to be aware of the configurations and environment variables/secrets that correspond to the current project and workspace. Those values are essential for the aio app deploy to work and are kept in two files .aio and .env.</p><p>Whenever you use aio app use to switch project or workspace, these two files will be overridden based on the project or workspace you select, as they are environment-specific.</p><p>It’s important to note that .env can be used for introducing the custom variables/secrets that are required for your application, and that the overriding will wipe them out as well. In this situation, you can keep a backup of .env per workspace like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/184/0*4NvQZm_sneO4y7pa" /></figure><p>So when the switching happens, you’re able to restore the corresponding values from the backup. But remember: never commit .env and those backups into code repo since they carry credentials and secrets.</p><p>As you can see here, an aio-CLI-based approach can quickly enable developers to deploy code. But apparently, it is not robust enough to scale, and risky in the sense that developers can inadvertently deploy code to an environment that was not intended.</p><p>For enterprise-level of code deployment, CI/CD is a must — and App Builder supports that too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/0*Q-q_IL-DQ35aQeFj" /></figure><p>App Builder offers OOTB support for <a href="https://developer.adobe.com/app-builder/docs/guides/deployment/ci_cd_for_firefly_apps/#github-actions-support">Github’s CI/CD</a>. Leveraging <a href="https://docs.github.com/en/actions/security-guides/encrypted-secrets">Github Secrets</a> to manage project/workspace configurations and environment variables/secrets is a huge relief compared to managing them in local .aio and .env files.</p><p><a href="https://docs.github.com/en/actions/using-workflows">Github Workflow</a> references those variables/secrets, and then invokes <a href="https://docs.github.com/en/actions">Github Actions</a> that eventually build, test and deploy code to the targeted project and workspace.</p><p>As per the above diagram, developers can still use aio CLI to deploy code to the dev workspace(s). This could be more efficient in cases where multiple developers own different workspaces.</p><p>But when it comes to code deployment to higher environments, pipeline deployment must be followed to mitigate the risk of accidental deployment and enhance governance with code quality checks, PR reviews, unit tests, and so on. Pipeline permission can also be set to enable more restrictions.</p><p>This approach is not limited to Github. Other enterprise-level DevOps or CI/CD tools can definitely implement the same process.</p><p>Now let’s take this a step further.</p><p>Imagine a situation where AEM’s code relies on some microservices deployed by App Builder to integrate with a 3rd party.</p><p>Such a situation may require two development teams — AEM and App Builder — to be coordinated when it comes to code deployment/release. One side may have version dependency on the other, or both sides may have to be on a coordinated version (i.e. the latest update). Otherwise, the integration may break, or produce unexpected results.</p><p>As most AEM developers know, AEM’s code deployment is done through Cloud Manager, while App Builder’s code deployment has to go through the CI/CD pipeline mentioned above.</p><p>Whenever AEM needs to deploy the latest code, the developer or deployment manager can ask the App Builder team to deploy the corresponding version.</p><p>This can work, but may become a bottleneck when a more frequent code deployment/release cadence is required. In this case, App Builder itself can help streamline the deployment process across systems.</p><p>Let’s assume both AEM and App Builder code are committed into the same Github code repo. If this is the case, we can do something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/0*Nj4d57e3sn5KZJo1" /></figure><p>Taking this step by step:</p><p><strong>Step 0: </strong>AEM code needs to be synced to CM’s repo, which is a common practice.</p><p><strong>Step 1:</strong> The AEM deployment manager starts a Production pipeline to deploy code to AEM Stage &amp; Prod (a non-Production pipeline can definitely do the same).</p><p><strong>Step 2:</strong> CM’s Production pipeline deploys code to AEM Stage &amp; Prod through various steps.</p><p><strong>Step 3:</strong> At minimum, CM’s <a href="https://developer.adobe.com/experience-cloud/cloud-manager/guides/api-usage/receiving-events/#pipeline-execution-started">Pipeline Start</a> event and <a href="https://developer.adobe.com/experience-cloud/cloud-manager/guides/api-usage/receiving-events/#pipeline-execution-step-started">Pipeline Execution Step Start</a> event can be subscribed in Adobe IO events. Since CM’s Production pipeline contains deployments for both Stage and Prod, the Pipeline Execution Step Start event here is to detect when the Prod deployment gets started.</p><p><strong>Step 4:</strong> A custom Adobe IO action (or webhook) can be implemented to handle the above-subscribed events. In this action, a “Pipeline Start” event can trigger App Builder’s code deployment to the corresponding Stage workspace. A “Deploy to Production” Step Start event can trigger App Builder’s code deployment to the Prod workspace</p><p>(There are other CM event <a href="https://developer.adobe.com/experience-cloud/cloud-manager/guides/api-usage/receiving-events/#step-actions">types/options</a> available. You can definitely have your IO action trigger App Builder code deployment, as per your needs).</p><p>Check this link to find out more about how to <a href="https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow">trigger a Github Workflow using REST API</a>.</p><p>If you want to ensure the same branch code is deployed for version consistency across AEM and App Builder, the CM git branch info can be fetched by the IO action then passed to the REST API as the ref param.</p><p>The overall intent of this coordinated code deployment strategy is not to try to fully tackle the challenge of the high availability of code across systems. This normally requires extra strategies and techniques, working in tandem.</p><p>However, this strategy does at least offer the option to automate some key processes, which gets us a little closer to that goal.</p><p><strong>Interested in finding out more? </strong><a href="https://medium.com/@kelvinxu88"><strong>Read more articles and tutorials by Kelvin Xu via the link.</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9c677cbfe5d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adobetech/app-builder-code-deployment-strategies-that-aem-developers-should-know-a9c677cbfe5d">App Builder Code Deployment Strategies that AEM Developers Should Know</a> was originally published in <a href="https://medium.com/adobetech">Adobe Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Register/Map Custom AEM I/O Events]]></title>
            <link>https://medium.com/adobetech/register-map-custom-aem-i-o-events-5f7782b26066?source=rss-c1d307980e2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f7782b26066</guid>
            <category><![CDATA[adobe-experience-manager]]></category>
            <category><![CDATA[adobe-io]]></category>
            <category><![CDATA[app-builder]]></category>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Kelvin Xu]]></dc:creator>
            <pubDate>Fri, 16 Jul 2021 21:21:29 GMT</pubDate>
            <atom:updated>2022-10-07T22:30:25.510Z</atom:updated>
            <content:encoded><![CDATA[<p>After setting up AEM I/O events following <a href="https://www.adobe.io/apis/experienceplatform/events/docs.html#!adobedocs/adobeio-events/master/using/aem-event-setup.md">this</a>, you will get the following AEM events mapped to I/O events OOTB and you can immediately hook them up with your I/O actions or webhooks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*zVv2d55VdLEIPc0bz8FYCg.png" /></figure><p>What if you want to map more AEM event types into I/O events such as asset_published or asset_metadata_updated? Here are the high-level steps. In general, what it takes is just to find the underlying OSGi event and map to a new I/O event code through a custom com.adobe.aio.aem.event.osgimapping.internal.OsgiEventMappingSupplierImpl factory config. Let&#39;s take asset_published and asset_metadata_updated events as examples.</p><p><strong>asset_published</strong></p><ul><li>Publish an asset and go to /system/console/events to find the event that can be uniquely identified by the event topic, path, and type. something like below,</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*teifR5OXRk8V3XOsboD3Fg.png" /></figure><ul><li>Use event topic, path, and type to define a custom OSGi config com.adobe.aio.aem.event.osgimapping.internal.OsgiEventMappingSupplierImpl-asset_published.cfg.json with below properties,</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/029b81e2681053644638606672382d66/href">https://medium.com/media/029b81e2681053644638606672382d66/href</a></iframe><p>A few things to note,</p><ul><li>This event only indicates asset is published from author, not necessarily meaning the asset has successfully reached to each publisher. For the latter, you can use osgi event topic org/apache/sling/distribution/agent/package/distributed.</li><li>com.adobe.xdm.event.AemPagePublishedEvent is reused as adobeIoXdmEventClassName (same as page_published event) for constructing the I/O XDM event payload. AemPagePublishedEvent provides xdmPublished as the event type.</li><li>!(event.application=*) is added to the osgiFilter to avoid the same event being emitted multiple times especially for clustered authors in AEMaaCS.</li><li>Once this config is deployed, an event payload would look like this in I/O console’s Debug Trace after you publish an asset.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06ad64c80202acefb9ad87f912aab95c/href">https://medium.com/media/06ad64c80202acefb9ad87f912aab95c/href</a></iframe><p><strong>asset_metadata_updated</strong></p><ul><li>Update an asset’s metadata and go to /system/console/events to find the event that can be uniquely identified by the event topic, path, and type. something like below,</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Umnq7CmD93y8nWhsGIfgKA.png" /></figure><ul><li>Use event topic, path, and type to define a custom OSGi config com.adobe.aio.aem.event.osgimapping.internal.OsgiEventMappingSupplierImpl-asset_metadata_updated.cfg.json with below properties,</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d446bfecf1fd9d59cfe9cdbb63842dc/href">https://medium.com/media/3d446bfecf1fd9d59cfe9cdbb63842dc/href</a></iframe><ul><li>Once this config is deployed, an event payload would look like this in I/O console’s Debug Trace after you update an asset’s metadata.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13ac055dca6b1ec22bee6349ee25acb3/href">https://medium.com/media/13ac055dca6b1ec22bee6349ee25acb3/href</a></iframe><p>You may notice asset_metadata_updated event is always followed whenever an asset_published event is fired. This is because certain metadata like cq:lastReplicated, etc. is updated after an asset is published.</p><p>The above mechanism can be extended to map custom <a href="https://sling.apache.org/documentation/bundles/apache-sling-eventing-and-job-handling.html">OSGi/Sling events</a> as long as your custom event can be uniquely identified by topic, path, and type.</p><p>The new AEM event types should be available in your I/O project for registration like this,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*ntliQZfzYiuB4IueD8VJnA.png" /></figure><p><strong><em>More references can be found at </em></strong><a href="https://www.adobe.io/apis/experienceplatform/events/docs.html#!adobedocs/adobeio-events/master/aem/aem_advanced_configurations.md"><strong><em>https://www.adobe.io/apis/experienceplatform/events/docs.html#!adobedocs/adobeio-events/master/aem/aem_advanced_configurations.md</em></strong></a><strong><em>.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f7782b26066" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adobetech/register-map-custom-aem-i-o-events-5f7782b26066">Register/Map Custom AEM I/O Events</a> was originally published in <a href="https://medium.com/adobetech">Adobe Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adobe I/O-Powered AEMaaCS Assets Export Implemented in Real-Time or Batch Mode]]></title>
            <link>https://medium.com/adobetech/adobe-i-o-powered-aemaacs-assets-export-implemented-in-real-time-or-batch-mode-95b8f275cca2?source=rss-c1d307980e2f------2</link>
            <guid isPermaLink="false">https://medium.com/p/95b8f275cca2</guid>
            <category><![CDATA[platform]]></category>
            <category><![CDATA[adobe-io]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[adobe-experience-manager]]></category>
            <category><![CDATA[app-builder]]></category>
            <dc:creator><![CDATA[Kelvin Xu]]></dc:creator>
            <pubDate>Fri, 16 Jul 2021 21:15:25 GMT</pubDate>
            <atom:updated>2023-01-12T16:27:27.219Z</atom:updated>
            <content:encoded><![CDATA[<p>AEMaaCS Assets offers a cloud-native digital assets management solution, which is scalable, reliable, and hassle-free. It’s never been a better time for enterprises to adopt such a solution as their centralized DAM system. To share or distribute assets (or their renditions), AEMaaCS provides multiple ways such as asset link share, asset selector, brand portal, etc. But still, there are common use cases where assets (or renditions) just need to be exported to external cloud storage like Azure blob store, S3 bucket, SFTP, etc. (for other systems to further consume) or directly into 3rd party systems like Marketo, Adobe Campaign, PIM, etc. as long as they provide secured asset ingestion endpoints.</p><p>Traditionally in AEM 6.x, this usually can be accomplished by “publishing” assets into downstream systems (within a workflow or something) via a custom replication agent. This won’t work in AEMaaCS since AEMaaCS is relying on <a href="https://experienceleague.adobe.com/docs/experience-manager-cloud-service/operations/replication.html?lang=en">content distribution</a> rather than replication agent anymore. There is also a paradigm shift in terms of how AEM should be integrated with external systems in a cloud world, which is more event-driven and microservices-based. In this sense, App Builder (Events and Runtime action) can really help bridge the gap.</p><p>Let’s take a look at a use case like this: upon assets publishing, assets’ original rendition (or with one or more other renditions) should be published/exported to either Azure cloud storage or a 3rd party system such as Marketo (eventually can support any 3rd party destination as long as it provides a public asset ingestion endpoint), which is driven by an export destination property defined in assets metadata, something like below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/1*ON1TW0gIZxUaiXd1tC9Ujw.png" /></figure><p>We will see how easily Adobe I/O can make it happen in either a real-time (sync) or a batch (async) fashion, with literally no custom code required in AEMaaCS. First of all, let’s quickly go over what Adobe I/O encompasses for implementing such use case.</p><h4>Adobe I/O Events</h4><p><a href="https://www.adobe.io/apis/experienceplatform/events/docs.html#!adobedocs/adobeio-events/master/readme.md">Adobe I/O Events</a> enables building reactive, event-driven applications, based on events originated from various Adobe services or solutions. In our case, the AEMaaCS author will be registered as the event provider. You can follow <a href="https://www.adobe.io/apis/experienceplatform/events/docs.html#!adobedocs/adobeio-events/master/aem/aem_skyline_install.md">this</a> to set up AEMaaCS I/O integration.</p><p><em>asset_published</em> is not an event type that comes with I/O event-proxy by default but you can follow <a href="https://medium.com/adobetech/register-map-custom-aem-i-o-events-5f7782b26066">this</a> to create a custom <em>asset_published</em> event mapping. Once event-proxy is successfully configured with <em>asset_published</em> mapping, you should get an event payload like below when publishing an asset,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06ad64c80202acefb9ad87f912aab95c/href">https://medium.com/media/06ad64c80202acefb9ad87f912aab95c/href</a></iframe><h4>Adobe I/O Runtime Action</h4><p><a href="https://www.adobe.io/apis/experienceplatform/runtime/docs.html#!adobedocs/adobeio-runtime/master/quickstart.md">Adobe I/O Runtime</a> is Adobe’s serverless computing platform, in which our actual asset exporting &amp; ingestion functions would be executed. Those functions are usually written in node.js and deployed to Runtime as “<a href="https://www.adobe.io/apis/experienceplatform/runtime/docs.html#!adobedocs/adobeio-runtime/master/overview/entities.md#actions">actions</a>&quot; but as a developer, you don’t need to worry about the overhead of spinning up or configuring servers. As the key ingredient of Adobe I/O event-driven application, runtime action can provide easy access to Adobe cloud services, data, and contents, orchestrate custom processes, and respond to Adobe I/O events.</p><p>I/O Runtime serverless platform is powerful, but we still need to be mindful of its <a href="https://www.adobe.io/apis/experienceplatform/runtime/docs.html#!adobedocs/adobeio-runtime/master/guides/system_settings.md">limitations</a> and find workarounds if necessary. Because of this, our implementations of asset export would differ (real-time vs. batch). We will talk more about them in the next sections.</p><h4>Adobe App Builder</h4><p>Adobe App Builder is a complete development framework that simplifies the processes of building and deploying custom Adobe I/O serverless applications. It is strongly recommended to leverage App Builder to implement any web (React SPA) or headless (microservices) application that runs on Adobe I/O serverless platform. App Builder provides the following convenient developer tools and services out of the box,</p><ul><li>aio CLI</li><li>SDKs for Adobe cloud services</li><li>Cloud storages for data and files</li><li>Seamless integration with Adobe IMS authentication</li><li>Developer console</li><li>CI/CD</li><li>CDN, etc.</li></ul><p>To save development effort and ensure best practices, our AEMaaCS assets export is a headless application that is initially bootstrapped from a <a href="https://www.adobe.io/apis/experienceplatform/project-firefly/docs.html#!AdobeDocs/project-firefly/master/getting_started/first_app.md">App Builder template</a>.</p><p>Now let’s take a look at how assets export can be implemented in an event-driven way powered by Adobe I/O events and actions.</p><h4>Webhook</h4><p>In Adobe I/O developer console, any AEMaaCS event of your interest can be subscribed, in our case, it is the “Asset Published” (<em>asset_published</em>) event we mapped earlier. Then assets export runtime action can be “web-hooked” up with that event directly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KkAHrnvZBWNSBHnVlekUzg.png" /></figure><p>The I/O event flow and handling can be depicted as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jBDKBKaXKzR0IQdP" /><figcaption>webhook</figcaption></figure><ol><li>An asset is published from AEM author to publisher.</li><li>“Asset published” event is sent to I/O events.</li><li>I/O events get notified and invoke the runtime action that is registered as the webhook. Event payload is also passed to the <a href="https://github.com/kelvinxzf/aemaacs-firefly/blob/master/manifest.yml#L24">assets export action</a> securely (see payload example above).</li><li>Assets export action parses event payload and gets the reference of the asset then makes a call back to AEM author to get more metadata (what kind of metadata is subject to particular use case. For our case, we use exportImmediately to determine whether to export now and exportDestination to determine to which destination the asset should be exported, such as Azure blob store, Marketo, etc.).</li><li>Assets export action fetches asset binary from AEM author and ingests it into the downstream system based on the specified destination. With the factory pattern, it is easy to extend <a href="https://github.com/kelvinxzf/aemaacs-firefly/tree/master/actions/aem-file-ingestors">FileIngestor</a> with any 3rd party system as long as it has a public asset ingestion endpoint.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6653093cf017f63da04e9c1ed225e738/href">https://medium.com/media/6653093cf017f63da04e9c1ed225e738/href</a></iframe><p>As you can see the whole event-driven flow happens in almost real-time. As soon as the asset is published from AEM author, the asset binary is immediately ingested into the destination system. This works well for individual asset publishing that is relatively small and fast. However, when facing a situation like bulk asset publishing (i.e. &gt; 100 assets), you may observe 429 error in the I/O console’s Debug Trace like below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oK1PI6wjXttSlVxpJuN-OQ.png" /></figure><p>This is because the concurrent <a href="https://www.adobe.io/apis/experienceplatform/runtime/docs.html#!adobedocs/adobeio-runtime/master/guides/system_settings.md">limit</a> (no more than 100 activations concurrently submitted per namespace) of I/O runtime has been reached. In such a situation, Adobe I/O events will <a href="https://www.adobe.io/apis/experienceplatform/events/docs.html#!adobedocs/adobeio-events/master/support/faq.md#what-happens-if-a-webhook-is-down">retry the request up to 5 times using an exponential backoff strategy within the next 31 mins</a>. Hopefully, during that window, the concurrent number of actions from your runtime namespace would drop under the threshold otherwise the export action/webhook would be marked as disabled and all of the inflight events would be unhandled and lost (events handled by webhook are fired-and-forgotten). If such a situation can’t be tolerated in your application, you may need to consider using the journaling approach.</p><h4>Journaling</h4><p><a href="https://www.adobe.io/apis/experienceplatform/events/docs.html#!adobedocs/adobeio-events/master/intro/journaling_intro.md">I/O events journal</a> is an ordered list of events. To consume it, you just need to use the journaling API endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wDIMGrO5enfWFAq07wpvHw.png" /></figure><p>The events will be persisted in the journal for up to 7 days, and your action can be defined as a scheduled/cron job that reads and processes them based on your pace, 10 events hourly, 50 events daily, etc. totally up to your needs. Unlike webhook’s real-time even handling, journaling is more suitable for batched asset processing/bulk exporting but with more guaranteed event handling since it is dependant on your action’s availability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AUTnsln56cAyOWUk" /><figcaption>journaling</figcaption></figure><ol><li>One or multiple assets are published from AEM author to publisher.</li><li>Bulk “Asset published” events are sent to I/O events and persisted in the I/O journal.</li><li><a href="https://github.com/kelvinxzf/aemaacs-firefly/blob/master/manifest.yml#L76">A scheduled/cron assets export action</a> fetches events (with event payloads) from the journal regularly and starts to process them. For the next action run to pick up where it left off, <a href="https://github.com/adobe/aio-lib-state">aio-lib-state</a> SDK is utilized here to store the last position that has been reached in the journal (see code snippet below).</li><li>For each event fetched, similar to the webhook approach, assets export action gets the asset reference and calls back to the AEM author to get more metadata.</li><li>For each asset, assets export action fetches asset binary from AEM author and ingests it into the downstream system.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ea3605106488c4bb8f82e643af08f6d/href">https://medium.com/media/8ea3605106488c4bb8f82e643af08f6d/href</a></iframe><p>As you can see, webhook (event <em>push</em> model) and journaling (event <em>pull</em> model) are both powerful event handling mechanisms. Usually for the use cases that require real-time handling with some short-lived actions, but the guarantee of event handling is not that critical (either can be recovered by retries or next runs), webhook is a great fit. On the other hand, if the execution of your events needs to be guaranteed and/or events emitting usually happens concurrently at a large scale, journaling is the right direction you should look into.</p><p><strong><em>Full Adobe I/O sample code for this use case can be referenced here </em></strong><a href="https://github.com/kelvinxzf/aemaacs-firefly"><strong><em>https://github.com/kelvinxzf/aemaacs-firefly</em></strong></a><strong><em>.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95b8f275cca2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/adobetech/adobe-i-o-powered-aemaacs-assets-export-implemented-in-real-time-or-batch-mode-95b8f275cca2">Adobe I/O-Powered AEMaaCS Assets Export Implemented in Real-Time or Batch Mode</a> was originally published in <a href="https://medium.com/adobetech">Adobe Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>