Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

How to find preview env agent id in preprocessor interface

Avatar

Level 3

Hi guys,

 

We are using preprecosser interface to handle one event. It is using below method.

 

public void preprocess(final ReplicationAction replicationAction, final ReplicationOptions replicationOptions

 

May i know how to get agentid for above method ? Below code i tried but it was throwing null for agent id. Same code works with event handler interface.

 

Event event = replicationAction.toEvent();

        final List<String> agentIdList = (List) event.getProperty("agentIds");

        LOG.info("preprocess agentIdList {}", agentIdList);

        final boolean isPreview = CollectionUtils.isNotEmpty(agentIdList) &&

                                    agentIdList.stream().anyMatch(id -> id.contains("preview"));

        if (isPreview)

{

            return;

        }

 

I want to figure out if the request is for Preview environment or for Publish env using agent ids. Please let me know if any one has inputs for this.

2 Replies

Avatar

Community Advisor

Hi @testtttt1,

You can try to use AgentConfig object from ReplicationAction object, to get agent configuration, and retrieve specific agent id.

replicationAction.getConfig().getAgentId();