Call Hangfire Job (Recurring Job) from external API - hangfire

I have been using Hang-fire in our project but had a question, Can i call a hangfire Recurring Job from an API?
For Example:
http://devmyproject.com/projectname/recurring is the url for Hangfire web application to get recurring job.
Now from my webApi project i want to call this Url and invoke a Job to run.
Is this Possible?
Thanks

In The HangFire Project i added an end points to make it an API to get the Requests and then run the Hangfire job. I added Fire and Forget Job to run the HangFire job.

Yes you can certainly perform hangfire functions by calling an API. Here is the function for creating a Hangfire job as listed on the front page of hangfire site.
RecurringJob.AddOrUpdate(
() => Console.WriteLine("Recurring!"),
Cron.Daily);
The URL you call should be an endpoint which you can pass parameters to. Then if hangfire is set up correctly it should be like any other application.

Related

Bot famework composer - Dependency injection in Custom Action

I am referring to this article for running a long running task in background while returning 200 response immediately in bot framework composer.
https://github.com/EricDahlvang/ImmediateAcceptAdapter
Here, instead of Thread.Sleep in Custom Action, I have to make an http call which sometimes takes more than 15 secs.
I need some help in injecting a service with http call in the Sleep Custom Action.

Log Laravel API calls to AWS Cloudwatch

I have been using this package (https://github.com/maxbanton/cwh) to setup logging in my laravel 8 app.
I can already send the logs properly and see them in Cloudwatch and what I am trying to do is to log the API calls (request and response). I was able to do this by doing it by adding it in the middleware. My only question is that how can you do this asynchronously? I have found this discussion posted as an issue and this was the suggested solution (https://github.com/maxbanton/cwh/issues/25#) but I couldn't figure out how to implement it.
Has anybody able to send API logs to Cloudwatch asynchronously? Thank you.
What you can try is sent the call to a queued job or listener (beanstalkd preferably as using DB as storage will probably take the same time as sending the log to AWS) that is not running on the sync queue.
This way you can fire the call off to something else, and that can deal with it without you waiting for it.

FLOWABLE: Authenticating flowable-task from another application via rest call

So, I am creating an application which will be using flowable.
We can say that once my application starts, it's gonna start a particular process deployed on flowable, proceed ahead accordingly.
So, in a way there will be lot of talking between flowable and other application, but for now suppose I just want to call flowable applications from POSTMAN (outside FLOWABLE).
I have used 3 modules: flowable-idm, flowable-modeler, flowable-task in my application.
Everything works fine when I am starting my deployed process from UI of flowable task, problems come when I want to start the processInstance using REST endpoint.
In flowable-task application, there is already a REST endpoint to start the process deployed: http://localhost:8080/flowable-task/app/rest/process-instances.
Now, if I call this from Swagger of flowable-task application, it works fine.
But it doesn't work when I try to call it from another application or POSTMAN for now (once POSTMAN call works, I can make the same arrangement in code), where I'm doing a basic auth and providing what's required in body.
Also, there is no error or exception displayed on console, I believe that is because of something catching that error or exception and not displaying anything.
However, to overcome the problem of starting process from POSTMAN, I can use REST endpoint http://localhost:9999/flowable-task/process-api/runtime/process-instances, but this is just a workaround, in future if I create new endpoints I would have to figure out a way to call those endpoints.
I saw this post and I guess this guy was also trying to achieve something similar but for flowable-modeler.
It's been suggested to make changes in SecurityConfiguration.java of flowable-task-conf module for my case, but I haven't done such changes before so not exactly sure where to start and how to proceed.
So, my question is how to talk to flowable-applications from outside flowable applications.
Edit:
Forum post about getting exception when imported flowable-rest module in workspace
The flowable-task UI Application is an example application that exposes non public REST API for the UI. However, the application also exposes the full REST API of Flowable.
There is also the flowable-rest application that has the Swagger doc and exposes the full REST API without a UI.
You would want to communicate with those REST endpoints.
The endpoints are under the following contexts:
process-api for the Process Engine
cmmn-api for the CMMN Engine
dmn-api for the DMN Engine
idm-api for the IDM Engine
form-api for the Form Engine
content-api for the Content Engine
For your example you would need to use POST to /process-api/runtime/process-instances for Starting a Process Instance

Repeatedly calling a web service in mule

I am working on a mule studio application in which I am calling a soap web service for getting status of a particular process. If the status is PENDING, I have to call the same web service until the status become COMPLETED. What approach I have to take for implementing this scenario.
Thank You in advance.
Take a look at the until-successful router: http://www.mulesoft.org/documentation/display/current/Until+Successful+Scope
You can configure the failureExpression to check if the status is 'PENDING'.
As Ryan Carter said, you can use the Until Successful router in order to achieve this.
You need to configure the failureExpression attribute to return 'true' if you want to call the web service again.
Note also that you can configure the until successful to be "synchronous" instead of the default "asynchronous". The former configuration does not require an object store.

WCF - run code after AppStart - but not in AppStart

i'm trying to set up some code that needs access the PerRequest lifestyle. this lifestyle can't be access from within the AppStart of the global.asax.
How can i effectively run initialization code on a wcf service outside of appstart?
this is so that i can configure what documents are versioned in my RavenDb - to do this i have to specify the perrequest ifestyle - doing this in app start throws an exception.
Code that use the PerRequest lifestyle runs by definition per request.
You could split your initialisation code in two parts
What is not dependant on the per request lifecycle runs in Application_start
What is dependant on per request lifecycle runs as the first code in each request
Typically the binding of your ioc containers should be in application_start