Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matthew Wise 188 posts 772 karma points c-trib
    Sep 08, 2016 @ 16:17
    Matthew Wise
    0

    Courier (v 2.52.14) Notifier events not firing

    I'm trying to fire a custom event when courier has finished publishing a node or all nodes sent.

    I have added the following listener in ApplicationStarted

    ExtractionManagerEvents.PostProcessedItem += ExtractionManagerEvents_PostProcessedItem;
    

    But the event is never triggered. I have ensured this code is being called on start up of both the sender and receiving sites.

    Anyone able to point me in the right direction.

  • Alex Lindgren 158 posts 355 karma points
    Feb 02, 2017 @ 22:35
    Alex Lindgren
    0

    I'm having the same problem. I have code to log every ExtractionManagerEvents event, but only ExtractedItemResources seems to fire...

    My code is at https://github.com/alindgren/UmbracoCourier.EventsLogger

  • JLon 300 posts 421 karma points
    Mar 20, 2017 @ 11:50
    JLon
    0

    Hey Alex,

    To make this simple I've got EnvA which i make amends and deploy to EnvB using courier.

    I've been using your EventsLogger to see if the ExtractedItemResources will be trigger, I've put in break points on all the events trigger including the ExtractedItemResources but I can't seems to get it trigger at all when I courier things across to EnvB.

    The event definitely loads as it hits into ApplicationStarted when the site first loads, but can't get into it anymore after that with Courier deploy.

    Any idea?

    Thanks

  • Alex Lindgren 158 posts 355 karma points
    Mar 20, 2017 @ 13:31
    Alex Lindgren
    0

    TheExtractedItem event has been fixed since I posted my code so that it now works. I get the GUID of the node with e.Item.ItemId.Id. One thing that was surprising for me is that this event happens on the sending environment (I guess all the processing happens there), so the receiving environment doesn't get the event triggered. I was expecting it to happen in the environment where it was extracted. It's a little unfortunate, but I've worked around this by calling an API on the receiving environment.

  • JLon 300 posts 421 karma points
    Mar 20, 2017 @ 14:22
    JLon
    0

    Aha so the event will only be triggered at the sending end but not the receiving end?

    Will you be able to share the code that you used for the receiving environment (the API calling that you have?)

    Thanks

  • Alex Lindgren 158 posts 355 karma points
    Mar 20, 2017 @ 14:52
    Alex Lindgren
    1

    The API code I have is very specific to my project. I am updating Relations for specific content types.

    But it's just an UmbracoApiController webmethod that takes a Guid as a parameter. I then get the node. Here's the code (removing the project specific stuff where I put the "do stuff with node" comment:

    [HttpGet]
        public void UpdateRelations(Guid guid)
        {
            try
            {
                var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
                var node = umbracoHelper.TypedContent(guid);
    
                // do stuff with node
            }
            catch (Exception ex)
            {
                LogHelper.Error<MyApiController>("Error for guid " + guid.ToString(), ex);
                throw ex;
            }
        }
    

    I have everything in a try/catch block because if there is an error, it doesn't seem to log/output a useful message.

  • JLon 300 posts 421 karma points
    Mar 20, 2017 @ 14:56
    JLon
    0

    Ic. You are calling this API from within your Sending environment within the ExtractedItemResources events.

    Eg your receiving site is Receiving.com

    So, in your Sending environment ExtractedItemResources event, you are calling your Receiving.com/umbraco/api/UpdateRelations/?guid=xxxxxxxxxxxxxx

    To trigger the update right?

  • Alex Lindgren 158 posts 355 karma points
    Mar 20, 2017 @ 15:02
    Alex Lindgren
    1

    I'm using the ExtractedItem event.

    Also, forgot to mention this - not sure if it's really needed -- but I was worried about overloading the server by making a lot of API calls all at once when many nodes are transferred, so I actually queue the calls to the API using Azure Storage Queue and then have the queue call the server using Azure Functions. Not sure this is needed but I already had it in place for other things.

    Here is my event handler code:

        private void ExtractionManagerEvents_ExtractedItem(object sender, ItemEventArgs e)
        {
            if (e != null && e.Item != null && e.Item.ItemId != null)
            {
                if (e.Item.GetType().Name == "Document")
                {
                    LogHelper.Info<RegisterEvents>("item " + e.Item.ItemId.Id + " (" + e.Item.Name + ") was deployed. [type is " + e.Item.GetType().Name + "; provider: " + e.Item.Provider.Name + "]");
                    string baseUrl = ConfigurationManager.AppSettings["ContentDeployTarget"]; // ContentDeployTarget
                    IndexingQueue.QueueNode(baseUrl + "/Umbraco/Api/MyApi/UpdateRelations?guid=" + e.Item.ItemId.Id, 0);
                }
            }
        }
    

    The QueueNode method just dumps the URL in the storage queue.

  • Alex Lindgren 158 posts 355 karma points
    Mar 20, 2017 @ 15:08
    Alex Lindgren
    0

    One other detail - I check the type to make sure it's a "Document" because I just want to the Document - I think the event also triggers for Property Data.

  • JLon 300 posts 421 karma points
    Mar 20, 2017 @ 15:09
    JLon
    0

    Ic. Thanks Alex

  • JLon 300 posts 421 karma points
    Mar 20, 2017 @ 15:06
    JLon
    0

    Ic. Thanks Alex, I'll try it out. Helps a lot

Please Sign in or register to post replies

Write your reply to:

Draft