Copied to clipboard

Flag this post as spam?

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


  • Markus Johansson 1619 posts 4549 karma points
    Sep 17, 2019 @ 11:44
    Markus Johansson
    0

    Console App with access to the published content cache

    Hi!

    I've been faced with a scenario where we need to do some heavy processing (create zip files) based on data both from custom db-tables and some data stored as Umbraco content (v8). Since the tasks are very heavy and will be long running we don't want to use a single web request to perform the processing. We're looking at something like hangfire, a windows service or a console app - either way the process will not be in the "web context".

    I've seen some examples of how to use the Services APIs from a console app like this for example: https://github.com/sitereactor/umbraco-console-example

    My problem is that I have some repositories that loads data from the content cache returning IPublishedContent that we convert into our domain model objects, something like:

    using (var ctx = _contextFactory.EnsureUmbracoContext())
    {
       var myContent = ctx.UmbracoContext.Content.GetByKey(contentKey);
       return MapToDomainModel(myContent));      
    }
    

    Given this scenario I was hoping for a way to use the Umbraco Content Cache outside of the web context (in a console app or in a Hangfire job). I'm not sure if this is even possible or recommended? Have anyone tried this with success or does anyone have any experience around this?

    It does not really matter if the startup of this process is slow since our background task will only run once every week or so.

    One solution that I've been thinking about is to perform a API-call from my background-process to get the data that I need - that would also work but I wanted to reach out here before I choose my path forward.

    Cheers!

Please Sign in or register to post replies

Write your reply to:

Draft