Custom Replication Agent problem

Avatar

Avatar
Validate 1
Level 2
Airtash
Level 2

Likes

6 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
Airtash
Level 2

Likes

6 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Boost 5
Boost 3
Boost 1
View profile
Airtash
Level 2

05-03-2019

Hi everyone! Im new with adobe aem, actually Im working with 6.4 and Im trying to create a custom replication agent.

My problem is that when I build the code into aem and select the "Serialization Type" into the agent it fail and I receiving
"Agent is not valid. ContentBuilder not available"

01.JPG

I have following the next steps:

>I have tried creating a new agent, add the serialization type (custom) and fail.

>Copying from an existing agent, and also fails.

Im implementing ContentBuilder and TransportHandler, I just have only some logs into the implemented methods,I already have looked into Nate Yolles example

http://www.nateyolles.com/blog/2016/01/aem-akamai-custom-replication-agent

Im not copying the code because I want to understand how it works, also I have noticed there are some deprecated features in the annotations used in this example,

I have fix that, but Im not sure at all if the new annotations are causing the problem, also I have checked some documentation but so far it was not very helpful.

Im only using the @component annotation as you can see in the following code Im currently using:

Any sort of help highly appreciated.

Thanks in advance!.

------------------------------- TRANSPORT HANDLER ------------------------------------------------

@Component(name = "Custom Agent",immediate = true, enabled = true)

public class MyTransportHandler implements TransportHandler {

public boolean canHandle(AgentConfig config) {

log.info("+++++FROM CANHANDLE!!++++++");

return true;

}

public ReplicationResult deliver(TransportContext ctx, ReplicationTransaction tx) throws ReplicationException {

        ReplicationActionType replicationType = tx.getAction().getType();

        log.info("+++++FROM DELIVER!!++++++");

return ReplicationResult.OK;

}

---------------------------------------------CONTENTBUILDER-----------------------------------------------

@Component (service = ContentBuilder.class, enabled = true, name = "name")

public class TestContentBuilder implements ContentBuilder{

public ReplicationContent create(Session arg0, ReplicationAction arg1, ReplicationContentFactory arg2)

            throws ReplicationException {

        // TODO Auto-generated method stub

        return create(arg0,arg1,null);

    }

    @Override

    public ReplicationContent create(Session session, ReplicationAction action, ReplicationContentFactory factory,

            Map<String, Object> parameters) throws ReplicationException {

  log.info("---- FROM CONTENT BUILDER -----");

return ReplicationContent.VOID;

    }

@Override

    public String getName() {

        // TODO Auto-generated method stub

        return "Test AK";

    }

    @Override

    public String getTitle() {

        // TODO Auto-generated method stub

        return "Test AK Description";

    }   

--------------------------------------------------------------------------------------------------------------------

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 250
MVP
Gaurav-Behl
MVP

Likes

250 likes

Total Posts

1,147 posts

Correct reply

283 solutions
Top badges earned
Boost 250
Establish
Give back 300
Give Back 50
Give Back 5
View profile

Avatar
Boost 250
MVP
Gaurav-Behl
MVP

Likes

250 likes

Total Posts

1,147 posts

Correct reply

283 solutions
Top badges earned
Boost 250
Establish
Give back 300
Give Back 50
Give Back 5
View profile
Gaurav-Behl
MVP

06-03-2019

My recommendation would be to copy-paste code and make it compile without any issues to isolate multiple issues (libraries vs AEM-version vs archetype vs your own source code related issues) that you're trying to deal with in a single shot. Once it compiles and you're able to test it then tweak per your requirements.

I copied that code as-is, modified a couple of libs in pom.xml and I don't see any ContentBuilder related error.

Answers (5)

Answers (5)

Avatar

Avatar
Validate 1
Level 2
Airtash
Level 2

Likes

6 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
Airtash
Level 2

Likes

6 likes

Total Posts

6 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Boost 5
Boost 3
Boost 1
View profile
Airtash
Level 2

29-03-2019

Just add the following annotation in the class ContentBuilder.

@Component (service = ContentBuilder.class, enabled = true,property={"name=akamai",Constants.SERVICE_RANKING +":Integer=1001"})

public class AkamaiContentBuilder implements ContentBuilder {

}

for TransportHandler

@Component(service = TransportHandler.class,immediate = true, enabled = true,property={Constants.SERVICE_RANKING +":Integer=1001"})

public class AkamaiTransportHandler implements TransportHandler {

}

Also there are other helpful links that explain the new annotations.

https://forums.adobe.com/message/10671360#10671360

http://www.sgaemsolutions.com/2017/07/migration-of-scr-annotations-to-osgi-r6.html

http://www.nateyolles.com/blog/2017/05/osgi-declarative-services-annotations-in-aem

Re: AEM 6.4 beta, Apache Sling JCR Resource Resolver not present

Avatar

Avatar
Give Back 3
Employee
vivekanand-mishra
Employee

Likes

9 likes

Total Posts

12 posts

Correct reply

1 solution
Top badges earned
Give Back 3
Give Back
Boost 5
Boost 3
Boost 1
View profile

Avatar
Give Back 3
Employee
vivekanand-mishra
Employee

Likes

9 likes

Total Posts

12 posts

Correct reply

1 solution
Top badges earned
Give Back 3
Give Back
Boost 5
Boost 3
Boost 1
View profile
vivekanand-mishra
Employee

05-12-2019

This is correct answer. The agent must have this - property = { "name=akamai", "service.ranking:Integer=1001" }

Avatar

Avatar
Validate 10
Level 3
pradeepdubey82
Level 3

Likes

16 likes

Total Posts

93 posts

Correct reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile

Avatar
Validate 10
Level 3
pradeepdubey82
Level 3

Likes

16 likes

Total Posts

93 posts

Correct reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile
pradeepdubey82
Level 3

30-03-2019

Thank you Airtash. It worked.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

29-03-2019

Avatar

Avatar
Validate 10
Level 3
pradeepdubey82
Level 3

Likes

16 likes

Total Posts

93 posts

Correct reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile

Avatar
Validate 10
Level 3
pradeepdubey82
Level 3

Likes

16 likes

Total Posts

93 posts

Correct reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile
pradeepdubey82
Level 3

28-03-2019

Hi,

I am also facing same issue,

  • Agent is not valid. ContentBuilder not available

created multi module aem project using archetype 15. Below is my content builder code

@Component(name="Custom Content Builder", service=ContentBuilder.class)

public class CustomContentBuilder implements ContentBuilder {

private static final Logger LOGGER = LoggerFactory.getLogger(CustomContentBuilder.class);

@Reference

    private ResourceResolverFactory resolverFactory;

public static final String NAME = "Custom Content Builder";

public static final String TITLE = "Custom Content Builder";

  public ReplicationContent create(Session session, ReplicationAction action,

   ReplicationContentFactory factory) throws ReplicationException {

  LOGGER.info("Inside create!!!");

  return ReplicationContent.VOID; 

}

public String getName() {

LOGGER.info("Inside getName!!!");

  return TITLE;

}

public String getTitle() {

LOGGER.info("Inside getTitle!!!");

  return TITLE;

}

public ReplicationContent create(Session session, ReplicationAction action,

   ReplicationContentFactory factory, Map<String, Object> arg3){

LOGGER.info("Inside create new!!!");

LOGGER.info("Action type ::: "+action.getType());

String pagePath = action.getPath();

LOGGER.info("Page Path ::: "+pagePath);

try {

Map<String, Object> authenticationInfo = new HashMap<>();

authenticationInfo.put(JcrResourceConstants.AUTHENTICATION_INFO_SESSION, session);

ResourceResolver resourceResolver = resolverFactory.getResourceResolver(authenticationInfo);

Page page = resourceResolver.getResource(pagePath).adaptTo(Page.class);

LOGGER.info("Page original path ::: "+page.getPath());

} catch(Exception ex) {

LOGGER.error("Error in create ::: ", ex);

}

  return ReplicationContent.VOID;

}

}

Please advise what dependencies you have modified to make it working?

Thanks,

Pradeep