Skip to main content
Level 2
Apr 17, 2024 9:21 AM UTC

How to find preview env agent id in preprocessor interface

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.

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

2 replies

lukasz-m
Community Advisor
Community Advisor
Apr 17, 2024 11:36 AM UTC

Hi @testtttt1,

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

replicationAction.getConfig().getAgentId();
Translate
testtttt1Author
Level 2
Apr 17, 2024 12:01 PM UTC

Hi @lukasz-m 

 

It is also throwing nulll

Translate