Custom Transport Handlers in AEM 6 | Community
Skip to main content
Peter_Puzanovs
New Participant
October 16, 2015
Solved

Custom Transport Handlers in AEM 6

  • October 16, 2015
  • 12 replies
  • 8299 views

Hi,

System has custom transport handler that handles content transportation to the external system. This code was working on 5.5. Stopped working on the AEM 6.

It's created by implements TransportHandler

@Component(immediate = true, metatype = false)@Service(TransportHandler.class)

The problem we are facing at the moment is that public boolean canHandle(AgentConfig agentConfig) { method is not being invoked during the replication. Instead the default Transport handler is being invoked.

How can do I force CQ to use our custom TransportHandler implementation instead of the standard one ?

By running debug log level on com.day.cq.replication.impl.transport

We can see that ServiceTracker, has bound TransporHandler.

We can also see that the invoked class is still com.day.cq.replication.impl.transport.Http

Thanks,

Peter

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

Hi,

This is a bug. Please file a DayCare issue referencing GRANITE-6117.

Alternatively (or as a short-term workaround), you can specify an alternate protocol in the URL. For example, if your URL was mycustom://localhost:4503/bin/receive?sling:authRequestLogin=1 (instead of http://localhost:4503/bin/receive?sling:authRequestLogin=1), your transport handler would always have the opportunity to handle the replication.

Regards,

Justin

12 replies

Employee
August 22, 2016

Hi Summit,

Isn't that at WARNING level? Rather than an exception in the error.log file?Please post the top of the stack trace

Regards,

Opkar

New Participant
August 22, 2016

My bad.For testing I was returning the canhandle() as true only.That was the root cause of the problem. Once I started it conditionally , it started working.

Thanks & regards

Sumit

New Participant
August 17, 2016

Hi Peter,

Tried disabling the reverse replication ,getting below now. If I remove the custom TransportHandler , normal publish happens as usual

org.apache.jackrabbit.oak.jcr.session.RefreshStrategy This session has been idle for 6 minutes and might be out of date. Consider using a fresh session or explicitly refresh the session.
java.lang.Exception: The session was created here:
    at org.apache.jackrabbit.oak.jcr.session.RefreshStrategy$LogOnce.<init>(RefreshStrategy.java:169)
    at org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl.login(RepositoryImpl.java:260)
    at com.adobe.granite.repository.impl.CRX3RepositoryImpl.login(CRX3RepositoryImpl.java:92)
    at org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl.login(RepositoryImpl.java:202)
    at org.apache.jackrabbit.oak.jcr.session.SessionImpl.impersonate(SessionImpl.java:294)
    at org.apache.sling.jcr.base.AbstractSlingRepository2.createServiceSession(AbstractSlingRepository2.java:187)
    at org.apache.sling.jcr.base.AbstractSlingRepository2.loginService(AbstractSlingRepository2.java:339)
    at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory.getResourceProviderInternal(JcrResourceProviderFactory.java:279)
    at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory.getResourceProvider(JcrResourceProviderFactory.java:209)
    at org.apache.sling.resourceresolver.impl.tree.ResourceProviderFactoryHandler.login(ResourceProviderFactoryHandler.java:172)
    at org.apache.sling.resourceresolver.impl.tree.RootResourceProviderEntry.loginToRequiredFactories(RootResourceProviderEntry.java:95)
    at org.apache.sling.resourceresolver.impl.CommonResourceResolverFactoryImpl.getResourceResolverInternal(CommonResourceResolverFactoryImpl.java:257)
    at org.apache.sling.resourceresolver.impl.ResourceResolverFactoryImpl.getServiceResourceResolver(ResourceResolverFactoryImpl.java:91)
    at com.adobe.cq.commerce.impl.promotion.PromotionManagerImpl.activate(PromotionManagerImpl.java:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Thanks & regards

Sumit

Peter_Puzanovs
New Participant
August 16, 2016

Hi Sumit,

As the exception tells you, there is a problem with your Reverse Replication.

Can you kindly check and un-tick the Reverse replication from your agent and try again?

Regards,

Peter

New Participant
August 16, 2016

Hi Peter,

May be I could not explain it properly.I did create a solr replication agent. But with that and the custom transport handler deployed , only custom transporthandler is called ( for both default and solr replication agent) and the normal replication is not happening.Getting exception like below :

om.day.cq.replication.ReplicationException: Unable to replicate content with no polling transport handler. Check configuration.
at com.day.cq.replication.impl.AgentImpl.poll(AgentImpl.java:549)
at com.day.cq.replication.impl.AgentReverseReplicationHandler.poll(AgentReverseReplicationHandler.java:92)
at com.day.cq.replication.impl.ReverseReplicator.poll(ReverseReplicator.java:144)
at com.day.cq.replication.impl.ReverseReplicator.run(ReverseReplicator.java:87)
at org.apache.sling.commons.scheduler.impl.QuartzJobExecutor.execute(QuartzJobExecutor.java:105)

 

What am I mssing ?

Thanks & regards

Sumit

Peter_Puzanovs
New Participant
August 16, 2016

Hi Sumit,

Yes, absolutely you should not do changes to the OOTB content publishing mechanism from Author to the Publisher.

Given you can navigate to /miscadmin#/etc/replication/agents.author you will see Classic UI screen with the New button.

The idea here is that for your Solr config you would not use OOTB Replication Agent, but create your own Replication Agent(imagine calling it Solr Replication Agent).

Your own Solr Replication Agent can be created by extending the OOTB Replication Agent, which is just a standard CQ5 template/component with the configuration dialog.

Regards,

Peter

New Participant
August 16, 2016

Do I need to write code for default replication agent too ?

Does not seem to be right approach. Can't we use default http handler for publish ?

New Participant
August 16, 2016

Do I need to write code for default replication agent too ?

Does not seem to be right approach. Can't we use default http handler for publish ?

New Participant
August 16, 2016

Hi Peter,

Thanks for your reply.I was expecting the same. Will try the above.

Thanks & regards

Sumit

Peter_Puzanovs
New Participant
August 15, 2016

Hi Sumit,

You need to create your own custom agent.

There is an excellent guide about replication in Akamai[1], it's fairly similar to what you would do for Solr.

You can see code example[2]

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

[2] https://github.com/nateyolles/aem-akamai-replication-agent/tree/master/ui.apps/src/main/content/jcr_root/apps

Hope it helps.

Regards,

Peter