I would like to get the notification about the status of the IronWorker task after its finished.
I tried to setup and incoming-webhook, but could not find any way to achieve this.
Update
I know how to setup incoming webhook in slack. I am finding a way to trigger this webhook by IronWorker after its completed. I just don't want to integrate the request code in my worker code.
Any help would be appreciated.
IronWorkers allow you to configure a UDP log feed. They tend to send logs to papertrailapp over this UDP feed. If you have ELK stack then try pointing to that. Most log aggregation frameworks have a detect and notify feature built in. So logentries or papertrail or ELK could then look for a log statement from your worker like DONE and notify you in email/slack/text etc.
If your worker has reached the end of its business logic safely then perhaps it is safe to assume that it can also send a REST request to slack on its own saying i'm done! And that such an action wouldn't be an extra burden or cause any additional failures ... try & see ... then share!
(a) you could queue a notification task in a "notification worker" queue as the last step in your workers ... if you want to reduce the chances of failures or retries caused by the notification code itself.
The current API doesn't show a way to register and receive notifications about worker status from iron.io itself ... it seems only polling based: http://dev.iron.io/worker/reference/api/
So you want to set up incoming webhook in slack. And you want to trigger them when the task is complete.
After registering the incoming webhook in slack, you will get the Webhook URL. Its of the form - https://hooks.slack.com/services/SECRET/SECRET
Now we have to make a post request to this url along with the data.
import requests
import json
url = 'https://hooks.slack.com/services/SECRET/'
payload = {'text': 'Random test',"username": "A slack bot","icon_url": "https://slack.com/img/icons/app-57.png","channel": "#abhinav_rai"}
r = requests.post(url, data=json.dumps(payload))
print r.text
print r.status_code
The Following is the python code to make request to the webhook url. This will post your data in the desired channel.
For more information: Visit https://api.slack.com/incoming-webhooks or comment below.
Related
currently I am working to creating telegram bot. Now I required to know is there is any API to send info messages (like the one we get during a user is added r deleted in a group chat)
Thanks in advance
What you want to do can be done using answerCallbackQuery method.
But first of all you have to create a CallbackQuery using InlineKeyboardMarkup to create inline keyboards you can follow the steps in this link.
After creating the callback query you have to answer it using one of the codes below:
if (update.CallbackQuery.Data == "CQ1")
{
await Bot.AnswerCallbackQueryAsync(update.CallbackQuery.Id,"Text",true,null, 0);
}
This way the message will look like a message box and will disappear after the user taps on OK. But if you use the code below, the message will show up and disappear automatically after a few seconds.
else if (update.CallbackQuery.Data == "CQ2")
{
await Bot.AnswerCallbackQueryAsync(update.CallbackQuery.Id, "Text", false,null, 30);
}
By the way, messages that are shown at times like adding a user to a
group are service messages and theses kinds of message can only be
sent by telegram server.
If my suggestion does not fix your issue you can use pinMessage method
that sticks a single message to the top of the page in groups and
channels. But note that you can only pin one message to a channel
or group and for pinning another message firstly you should unpin the
previous one.
Currently there is no way to send such info messages.
And in my opinion, this feature is unlikely to be added in future because:
info messages usually tell you information about your chat; they are managed by telegram servers
therefore they should not be sent by Users
bot is an instance of User
I have a mule flow that has to work the following way.
HTTP listener listens to incoming calls and immediately responds with a job id.
The incoming message is queued into a worker. It works on it for a while and returns the message back to the sender.
I tried using non-blocking flow. But it didn't work. How is such a thing architected in Mulesoft? Would be great to have any leads on this.
Sounds like you could use an async scope for that second part. This would allow the HTTP listener to trigger that part and yet respond immediately with a response.
flow one Http listner---->Async Vm queue ---->set Jon ID--->Send response
Flow two VM inbound--->Process message-->Http requestor
The documentation for IronMQ push queues describes how endpoints should handle/respond to push messages. However, I get the impression this is for normal webhooks and I can't find any documentation or examples of what to do when the endpoint for a push queue is an IronWorker.
Does the IronWorker framework take care of responding to the IronMQ service when it starts a new IronWorker task for the message pushed onto the queue, or does my IronWorker code need to handle the response? If I need to handle it in my code, are there any variables automatically provided to me that represent the webhook request and/or response?
As I mentioned above, I've looked for example code but all I've found are IronWorker webhook examples that receive POSTs from something like GitHub, not from IronMQ. If there are examples out there for what I'm trying to do please point me to it!
There's actually a special subscriber format just for IronWorker as specified in the Push Queue documentation here: http://dev.iron.io/mq/reference/push_queues/#subscribers . Eg:
ironworker:///my_worker
That will kick off a worker task whenever something hits your queue. Or you can use the worker's webhook URL. And you don't need to deal with the response, as #thousandsofthem said, IronWorker will return a 200 which acknowledges the pushed message.
IronWorker API will respond immediately for a post request with "HTTP 200 OK" status and queue a task after that, it's too late to respond something from running task.
You could find exact webhook value on "Code" page (https://hud.iron.io).
Screenshot: http://i.imgur.com/aza7g0h.png
Just use it "as is"
Can anyone give me examples of how in production a correlation id can be used?
I have read it is used in request/response type messages but I don't understand where I would use it?
One example (which maybe wrong) I can think off is in a publish subscribe scenario where I could have 5 subscribers and if I get 5 replies with the same correlation id then I could say all my subscribers have received it. Not sure if this would the be correct usage of it.
Or if I send a simple message, the I can use the correlation to guarantee that the client received it.
Any other examples?
A web application that is providing HTTP API for outsiders for performing a processing task and you want to give the results for the caller as a response to the HTTP request they made.
A request comes in, message describing the task is pushed to queue by the frontend server. After that the frontend server blocks to wait for response message with the same correlation id. A pool of worker machines are listening on queue and one of them picks up the task, performs it and returns the result as message. Once a message with right correlation id comes in, frontend server continues to return the response to the caller.
In the context of CQRS and EventSourcing a command message correlation id will most likely get stored togehter with the corresponding events from the domain. This information can later be used to form an audit trail.
Streaming engines like Apache Flink use correlation ids, much like you said, to guarantee exactness of processing.
Most of the examples that I've seen on Workflow Services put activities between the Receive and SendReply activities. However, if the activities take a long time to complete the service timesout. I could increase the timeout or put the activities after the SendReply. Is there a best practice on where to run these activities?
There is no need to keep all activities between Receive and send reply. Your activities will be executed after completion SendReply activity. For a log running process send reply can send its client message related that service is started or any exception. Workflow will be executing after sendreply completion.
You can follow this approach..
1. Put receive activity as first activity on the workflow.
2. Apply validation on Data contract used as argument.
3. Put a code activity that can set WorkflowinstanceID in out parameter that can return as response from send reply. This is can
be used to control Workflow.
4. Add another send reply by right click on Receive activity, return response if any validation faults occur.
5. Put rest of activity below of send reply configure service behavior for any unhandled exception.