Define and send jobs from external applications

Hello,

I am relatively new to Hangfire and currently considering implementing it in a production context. I want to use external applications to send jobs to a server where Hangfire will run on. Is it possible to use external applications to enqueue jobs with not only the parameters relevant for said job but also the implementation logic and how would I describe implementation in a standardized process?

2 Likes

I’m not sure what you mean by ‘sending logic’, but if you mean to send the code to be executed, it does not sound like the normal way of doing things.

The relationship between the client - the one queuing the job - and the server - the one executing the job - normally consist of the client telling what to do, and the server knowing how to do it.

One common way of doing that is to have two assemblies in the server app: one with interfaces describing what jobs the server knows how to execute, and one with the actual implementation. The one with the interface will be shared with the clients.

Of cause, it’s possible to turn this around, and have the clients implement a assembly with jobs for each client, and publish this assembly. The server could load these assemblies and then be able to execute the jobs.

The result would be the same: at runtime, all the execution logic will be present at the server.

The difference is more of a code organization-thing. If the code should be in the server or client code repository.

That said - it is possible to do most whatever you want. E.g. you could send JavaScript code as an string and have the server execute it, but i wouldn’t go that way…

1 Like