Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Custom Transport Handlers in AEM 6

Avatar

Community Advisor

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

1 Accepted Solution

Avatar

Correct answer by
Employee

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

View solution in original post

13 Replies

Avatar

Correct answer by
Employee

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

Avatar

Level 1

Hello Justin,

I can't thank you enough for your swift and effective solution to the GRANITE-6117 bug. Your recommendation to specify an alternate protocol in the URL worked like a charm, and I'm thrilled to share that my replication processes are now running seamlessly. This approach is a game-changer!

For anyone encountering a similar challenge, I highly recommend trying the alternate protocol method—it resolved my issue for my site https://www.shipvehicles.com/ perfectly.

By the way, if you ever need reliable vehicle shipping services, don't hesitate to check out how we excel. Your expertise has made a significant impact on my operations.

Best regards,

Avatar

Level 4

I am facing same issue.Though the above solution worked and the custom TransportHandler called , but the regular publish didn't work due to the protocol change.

I need to publish the content as well as push the content to Solr instance.

How can I achieve the same ?

Thanks & regards

Sumit

Avatar

Community Advisor

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_...

Hope it helps.

Regards,

Peter

Avatar

Level 4

Hi Peter,

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

Thanks & regards

Sumit

Avatar

Level 4

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 ?

Avatar

Level 4

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 ?

Avatar

Community Advisor

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

Avatar

Level 4

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

Avatar

Community Advisor

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

Avatar

Level 4

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

Avatar

Level 4

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

Avatar

Employee

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