Closed doorman02 closed 2 years ago
What would be your use case? What would be your expectation?
If you would create an InstantTrigger via AddJobs
that would mean the job would run immediately once the server starts?
@linkdotnet thanks for your quick reply. Basically I want to be able to trigger the job via the API. So I am using the following endpoint:
$url = "http://localhost:port/jobs/$jobId/triggers/$triggerId"
However, I assume I will need the Id of the instant trigger to be able to trigger the job using the endpoint? or is there another way to trigger the job via api?
There is a package called jobbr-webapi
: https://github.com/jobbrIO/jobbr-webapi
If you want to map the request on your own you can have a look into the code of tje webapi: https://github.com/jobbrIO/jobbr-webapi/blob/cf8a2491a3f055e97ed543befdf15e574582e42a/source/Jobbr.Server.WebAPI/Controller/TriggerController.cs#L110
Thanks, for now I think I will just create the instant trigger from the dashboard and afterwards trigger it from the endpoint.
Ok. @doorman02 but you could do this via Web API. The url in the second link would be your target. Alternatively install the Jobbr.WebAPI nuget package and use the strongly typed library. Are you fine when I close the issue?
To recap: Only the Job has to be defined. Once this is done you can create an instant trigger via Dashboard / URL (HTTP POST( or the Jobbr WebAPI (which is a wrapper for all API Requests). This will create a JobRun which actually does your stuff
@linkdotnet thanks for the clarification. Since I may be posting a new instant job multiple times is it possible to delete older instant triggers via the api? or even better is there a way to re-trigger an already defined instant trigger?
Hey @doorman02 could you descirbe what you mean with "is it possible to delete older instant triggers via the api"
Once an Instant Trigger is older than DateTime.Now
it will not be picked up by the scheduler.
There is no endpoint for retriggering and old trigger, so I would advice you the have some logic in your program which saves the HTTP POST Request to the jobbr-server which creates the trigger in the first place. Basically you can just send the same request again.
@linkdotnet thanks this works. If I understand it correctly each time I call post a new instant trigger is created in the trigger list. My only concern was that the list would grow very large in the long run but it's maybe not that critical.
Yes. The list will grow over time that is correct. If this every becomes a problem you can just create a recurring job which delete "old" JobRuns / Triggers on the database level. If you have any other questions let me know @doorman02 .
Are you fine with closing the issue?
yes, thanks
I am triggering a job via the api and I was wondering if it is possible to specify an instant trigger using the
.WithTrigger();
syntax? e.g.