Velir / akamai-ccu-rest-api-connector

15 stars 12 forks source link

Query - Configuration for Publish instance #11

Open ajaygates opened 5 years ago

ajaygates commented 5 years ago

Hello Team, I am trying to move the Akamai connector from AEM Author to AEM Publish. I made the config changes like 'adobe/granite/replication' instead of 'com/day/cq/replication' on publish side. I am able to see the logs updated however its not able to get the 'activated paths'.

Here is the akamai.log from Publish env

JUANCITO aem-sprint-akamai-bundle started 28.11.2018 14:29:59.963 INFO [Thread-20] com.velir.aem.akamai.ccu.impl.AkamaiEventHandler Start handling event to add Akamai job 28.11.2018 14:29:59.964 INFO [Thread-20] com.velir.aem.akamai.ccu.impl.AkamaiEventHandler THIS IS PUBLISH 28.11.2018 14:29:59.964 INFO [Thread-20] com.velir.aem.akamai.ccu.impl.AkamaiEventHandler Paths to flush null 28.11.2018 14:29:59.967 INFO [Thread-20] com.velir.aem.akamai.ccu.impl.AkamaiEventHandler Event details com/adobe/granite/replication 28.11.2018 14:29:59.967 INFO [Thread-20] com.velir.aem.akamai.ccu.impl.AkamaiEventHandler null has no valid path(s) to purge. No Job added

Not sure what is missing here.

ajaygogate commented 5 years ago

Hi @kairas - Is this a simple change in config?

kairas commented 5 years ago

So... Event handler that comes with the bundle is com/day/cq/replication which only occurs on author.

BUT - The bundle decouples the service from the event handler so that anyone can create their own event handlers for this exact purpose.

On publish instances the event I would actually listen for is org/apache/sling/api/resource/Resource/CHANGED since it actually contains a path property (unlike adobe/granite/replication). Your event handler should make sure that the path is part of the pathsHandled configuration so you aren't making API requests for undesired paths like inside /var

kairas commented 5 years ago

Built in event handler uses "paths" property as a constant instead of "path" which is the property used by the resource change event so new event handler will be needed instead of property change. Though the amount of code needed would be minimal in your project.

Would recommend using org.apache.sling.settings.SlingSettingsService to check run mode to ensure that the event handler only functions on the publish instance and if you have multiple publish instances it only runs on 1 of them.

kairas commented 5 years ago

@ajaygates @ajaygogate Let me know if I can help in any other way

ajaygates commented 5 years ago

Thanks Kai for your comments.

If I understand correctly, I need to write a new EventHandler similar to what is there already.

However I have question on "paths" and "path" constant. At present this is defined in : FlushAkamiItemsJob. file

     public static final String PATHS = "paths"

So If I am not supposed to use 'paths' and required to use 'path' - does that also mean I need to change the "FlushAkamiItemsJob" code as well?

Or If I can re- define that variable and call it like this : public static final String PATH = "path" String[] path = PropertiesUtil.toStringArray(event.getProperty(FlushAkamaiItemsJob.PATH))

Please let me know

Thanks & Regards Ajay

On Thu, Dec 6, 2018 at 8:11 AM Kai Rasmussen notifications@github.com wrote:

@ajaygates https://github.com/ajaygates @ajaygogate https://github.com/ajaygogate Let me know if I can help in any other way

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Velir/akamai-ccu-rest-api-connector/issues/11#issuecomment-444883256, or mute the thread https://github.com/notifications/unsubscribe-auth/ATvvQDlHwvS-xDdwvoVHInhUqH85mjoWks5u2SWugaJpZM4Y4Zjl .

-- Thanks & regards

Ajay Gogate

kairas commented 5 years ago

The path property will be on the event

org.apache.sling.commons.osgi.PropertiesUtil.toString(event.getProperty("path"))

'paths' is the property to set when running the job topic com/velir/aem/akamai/ccu/impl/FlushAkamaiItemsJob

jobManager.addJob("com/velir/aem/akamai/ccu/impl/FlushAkamaiItemsJob ", [paths:["/content/foo"]])

ajaygates commented 5 years ago

Thank you so much Kairas for your inputs. I have done the changes in my eventhandler code (AkamaiEventHandler)

ts detecting the 'CHANGE' and tries to trigger purge job - but it fails with some method exception.

Also I see the job gets triggered for any asset irrespective of using "/content" filter. Attaching the file for your reference.

Sorry to bother you. If at all possible can you guide me to the fix for this.

Error seen in error log is : 06.12.2018 16:04:11.906 ERROR [sling-threadpool-2d7efe9e-3ba4-4d0c-a187-8dc2bb5d1546-(apache-sling-job-thread-pool)-51-Akamai Job Queue(com/velir/aem/akamai/ccu/impl/FlushAkamaiItemsJob)] org.apache.sling.event.impl.jobs.queues.JobQueueImpl.Akamai Job Queue Unhandled error occured in job processor No signature of method: com.velir.aem.akamai.ccu.impl.FlushAkamaiItemsJob.getPathsToPurge() is applicable for argument types: (org.apache.sling.event.impl.jobs.JobImpl) values: [JobImpl [properties=org.apache.sling.api.wrappers.ValueMapDecorator@939f54a0 : {slingevent:application=caaafbb2-70b7-45e6-ba85-451748029f8c, jcr:created=java.util.GregorianCalendar[time=1544133851888,areFieldsSet=true,areAllFieldsSet=true,lenient=false,zone=sun.util.calendar.ZoneInfo[id="GMT-06:00",offset=-21600000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2018,MONTH=11,WEEK_OF_YEAR=49,WEEK_OF_MONTH=2,DAY_OF_MONTH=6,DAY_OF_YEAR=340,DAY_OF_WEEK=5,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=4,SECOND=11,MILLISECOND=888,ZONE_OFFSET=-21600000,DST_OFFSET=0], slingevent:created=java.util.GregorianCalendar[time=1544133851874,areFieldsSet=true,areAllFieldsSet=true,lenient=false,zone=sun.util.calendar.ZoneInfo[id="GMT-06:00",offset=-21600000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2018,MONTH=11,WEEK_OF_YEAR=49,WEEK_OF_MONTH=2,DAY_OF_MONTH=6,DAY_OF_YEAR=340,DAY_OF_WEEK=5,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=4,HOUR_OF_DAY=16

Thanks in advance!!

On Thu, Dec 6, 2018 at 12:56 PM Kai Rasmussen notifications@github.com wrote:

The path property will be on the event

org.apache.sling.commons.osgi.PropertiesUtil.toString(event.getProperty("path"))

'paths' is the property to set when running the job topic com/velir/aem/akamai/ccu/impl/FlushAkamaiItemsJob

jobManager.addJob("com/velir/aem/akamai/ccu/impl/FlushAkamaiItemsJob ", [paths:["/content/food"]])

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Velir/akamai-ccu-rest-api-connector/issues/11#issuecomment-444987104, or mute the thread https://github.com/notifications/unsubscribe-auth/ATvvQGfLmF6DhdTbWFsHUsm-XOtdOUAJks5u2Wh2gaJpZM4Y4Zjl .

-- Thanks & regards

Ajay Gogate

kairas commented 5 years ago

Let me try to reproduce the issue and get back to you. I might need a couple of days. Can you try doing a remote debug from source control and see if you can see what the issue is yourself in the meantime?

Can you provide what version of AEM you are using and the code for your event handler?

ajaygates commented 5 years ago

Sure, I will continue my work as well - in debugging and fixing Re sending my code. I have AEM 6.3 version

Thanks Ajay

On Thu, Dec 6, 2018 at 5:23 PM Kai Rasmussen notifications@github.com wrote:

Let me try to reproduce the issue and get back to you. I might need a couple of days. Can you try doing a remote debug from source control and see if you can see what the issue is yourself in the meantime?

Can you provide what version of AEM you are using and the code for your event handler?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Velir/akamai-ccu-rest-api-connector/issues/11#issuecomment-445066921, or mute the thread https://github.com/notifications/unsubscribe-auth/ATvvQHv3iM5DE2bR_Vlq6Nm_FjK82X9jks5u2abagaJpZM4Y4Zjl .

-- Thanks & regards

Ajay Gogate

ajaygates commented 5 years ago

Hi Kairas, I was able to get this working for a path activated under '/content/'. However it does not work for a node activation under '/etc'. I will email you the changed 'AkamaiEventHandler' code.

Please have a look if you get a chance.

Thank you

On Thu, Dec 6, 2018 at 7:12 PM Ajay Gogate ajaygates@gmail.com wrote:

Sure, I will continue my work as well - in debugging and fixing Re sending my code. I have AEM 6.3 version

Thanks Ajay

On Thu, Dec 6, 2018 at 5:23 PM Kai Rasmussen notifications@github.com wrote:

Let me try to reproduce the issue and get back to you. I might need a couple of days. Can you try doing a remote debug from source control and see if you can see what the issue is yourself in the meantime?

Can you provide what version of AEM you are using and the code for your event handler?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Velir/akamai-ccu-rest-api-connector/issues/11#issuecomment-445066921, or mute the thread https://github.com/notifications/unsubscribe-auth/ATvvQHv3iM5DE2bR_Vlq6Nm_FjK82X9jks5u2abagaJpZM4Y4Zjl .

-- Thanks & regards

Ajay Gogate

-- Thanks & regards

Ajay Gogate