Giter Club home page Giter Club logo

Comments (8)

BredStik avatar BredStik commented on June 8, 2024 1

Nuget version 1.1.0 released with the new changes!

from hangfire.windsor.

IanYates avatar IanYates commented on June 8, 2024

I ended up rewriting this in my own codebase where I have a Windsor Job Activator that works in tandem with a globally installed job filter.
The job filter sees the start of a job, which happens on a specific thread. It tells the job activator of this, which sets up a child Windsor container in a thread local. On the same thread, Hangfire then executes the job and asks the Windsor Job Activator to create its types. The job activator gets the child container from the thread local and does its thing.

When the job is finished, the job filter tells the job activator to dispose of the child container created specifically for the thread.

I got the idea from reading a few different approaches people had taken with other IOC containers and Hangfire. Note that I think Hangfire 1.5+ has some additional IOC hooks which may make some of this no longer required.

I put an extract of my code in a gist
https://gist.github.com/IanYates/29180ce09c41e42b9a7e

Hope it's of some help.

from hangfire.windsor.

IanYates avatar IanYates commented on June 8, 2024

@BredStik - could I perhaps create a PR against this repo and, if so, could you then update NuGet?

from hangfire.windsor.

hikalkan avatar hikalkan commented on June 8, 2024

I implemented in other way. Can you check it: https://gist.github.com/IanYates/29180ce09c41e42b9a7e#gistcomment-1677285
Thanks a lot.

from hangfire.windsor.

IanYates avatar IanYates commented on June 8, 2024

(referring to your comment on the Gist)
The job activator scope is the new thing introduced in Hangfire 1.5. The old approach still works but the newer approach is probably better. I haven't updated to 1.5 since I didn't want to reverify the correct Windsor behaviour again.

In the code you've posted I don't see any Windsor usage - is it hidden behind the IIocResolver?

The approach seems pretty sound though. Certainly it's less hacky :)

Thanks!

from hangfire.windsor.

hikalkan avatar hikalkan commented on June 8, 2024

IIocResolver is ASP.NET Boilerplate's IOC abstraction. You can use same by sending Windsor Container directly. As I test, it's properly working.

from hangfire.windsor.

BredStik avatar BredStik commented on June 8, 2024

I created a new branch specifically to support 1.5 + version of Hangfire. Please feel free to submit a pull request that would use the job activator scope.

from hangfire.windsor.

BredStik avatar BredStik commented on June 8, 2024

Thanks to @jeroenvervaeke , this issue is closed! Will update the nuget package soon.

from hangfire.windsor.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.