Server Sent Events using Spring WebFlux, EventSource and RabbitMQ - rabbitmq

I want to create live notifications for my website.
Reference link: http://sinhamohit.com/writing/spring-boot-reactive-sse
Above link contains example for SSE and Event Source. The stream of objects is created to create Flux stream.
In my case, I want to create server sent events and send them to RabbitMQ server, the rest controller should be able to listen to message queue and receive the message.
Right now I am able to receive the messages, but I am not sure how I can convert them into Flux and send the stream to rest URL.
How should I do it?
Refernces, links and examples will be great.

Refer following link, here activemq is used but you can also use RabbitMQ.

Related

Can you add a Nagios Acknowledgment URL to Slack messages

I'm new to nagios and my first task has been slack integration. I am using the Nagios created plugin for Slack and everything is working correctly as far as posting the message in the channels for both hosts and services. I want to add an acknowledgment URL to the message that gets sent to slack, so our team can just acknowledge through the slack message. I have tried adding the URL in various places, like the host/service definitions so I could then call it in the command Slack_notification_handlers. Is it possible to add said acknowledgement urls with the current methods I'm using? or is this something I'm going to have to make myself?

SAP Cloud SDK JS receives empty data from Enterprise Messaging Queue

I have build a simple cloud-SDK based application for adding as a Webhook in Enterprise messaging queue to receive the events as soon as it gets inside the queue.
I have an OPTIONS and POST function. OPTIONS is for the handshake with the queue and it works.
Now, when there is message in the Queue, it hits my application with the POST block but the request body is coming as empty object.
I have tried the same from the postman, i'm able to receive the data in request body. Only from the Enterprise messaging queue, the data is empty.
In contrast, to verify this, I have used a Express based nodejs application, there i'm able to receive the data from the queue.
What am i missing in the Cloud-SDK based code ?
POST block, looks like this
#Post('ems-events')
receiveEmsEvents(#Body() requestBody: string, #Req() req:Request) {
Logger.log("Event Received with Data:");
Logger.log(requestBody);
Logger.log(req.body);
Logger.log("Log over--");
Logger.log(Object.keys(req));
return {};
}
The SAP Cloud SDK for JavaScript does not offer any support for Enterprise Messaging as of today. The code you're writing here is most likely Nest.js code, which is an independent framework.
That being said, Nest.js does run Express.js under the hood by default. So if you've been able to make it work in Express, you should be able to make it work in Nest.

Is it possible to retrieve more than 400 messages from ActiveMQ queue via Jolokia API?

I have an error queue in ActiveMQ, which is populated by Apache Camel's onException error handler. There could be thousands of messages in this queue.
Instead of using the ActiveMQ web console, I am building a custom web admin to integrate several other statistics from other components as well. Thus, I wanted to include the statistics from ActiveMQ as well.
ActiveMQ version: 5.14.3
I have looked at Jolokia JMX API, and its operations. For instance, I have the following payload to the broker's Jolokia API endpoint:
{
"type": "exec",
"mbean": "org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=test.errors",
"operation": "browse(java.lang.String)",
"arguments": ["EXCEPTION_TYPE LIKE '%jdbc%'"]
}
The header field EXCEPTION_TYPE is already populated via Apache Camel Route. I have more than 10k messages in this queue at the moment. I made a POST request to my broker API endpoint with the payload as shown above. Although I had more than 10k messages, this request resulted in just 400 messages (due to the max page size limitation, hard coded in the source code). This means that I will not be able to get more than 400 messages at a time via Jolokia. I also tried the browseMessages() method as well. Looks like, it does the same thing, in general.
Is it possible to browse these messages (let's say if they are high in number, may be around 10k+)?
Or, is it possible to paginate them? I could not see a relevant operation method for that.
I tried to see if Hawtio did something special in retrieving all the messages. But, the result is same( with max 400 messages).
ActiveMQ web console does fetch all the messages. This probably could be because it is tightly coupled with the ActiveMQ project.
I am not restricted to just JMX/Jolokia. If these stats can be fetched via some API, its equally fine.
Any inputs would be great !

receiving an input file dynamically and put my mule application in listening

Scenario:
- An application want to send a push to a list of device.
- so she sends information to my mule application which must be listening to the arrived information.
- My application will send this information via web service to the application which will send the push and then my application will wait for a response which is a json file with content: success: 0/1 failed: 0/1,
- according to this answer my mule application will send email which i take from the database, if the device concerned didn't receive the push.
I have done the last part of this scenario. from the receipt of the answer of the push. Now I have some questions about the first part:
I guess that the application sends a json file that contains a list of information of each device.
How processed the list of information devices. I must loop on the contents of the json file. any example of this?
How to put my application in listening for the arrivals request for sending push?
is the http connector sufficient? if so how to configure the path variable.
I'm using mule 3.5.0 CE, Thank you in advance.
Lets break this down, to the various components:
Sender Application - this is the service that needs to communicate with the devices.
Device Controller - this is the application that talks to the hardware devices.
Proxy - this is what you are developing on the Mule ESB. It will connect to both the Sender Application, and the Device Controller and transfer the request from Sender to Controller; and then send the results from the Controller back to the Sender.
The flow would look something like this:
Sender Application needs to communicate with devices.
Sender Application transmits information using JSON.
Proxy receives this JSON request.
The Proxy then contacts the Device Controller over HTTP.
The Device Controller only talks to the Proxy, and returns a result of 0 or 1 depending on the result from the physical device.
The Proxy then needs to communicate this result to the Sender Application.
At first, you might think to develop your Proxy over HTTP (using the HTTP Connector). This connector creates a web service endpoint (a website, basically) that can listen and respond to requests.
The Sender Application connect to this endpoint over HTTP and submits the JSON document containing the commands to be executed.
Your proxy then immediately contact the Device Controller (again, over HTTP using the same connector).
The device controller talks to the devices, and then returns the response to your Proxy (over HTTP).
You take this response and then send it back as the response to the original HTTP request (from the Sender Application).
The problem here is if there is any delay between your connection and the Device Controller (or the Device Controller and the physical devices), the connection will remain blocked on both sides (since you need to send a response).
If there is a large delay the HTTP connection between your Proxy and Sender Application may terminate.
This is the same when some site is overloaded and doesn't respond - eventually the browser will timeout.
To avoid this scenario, split your integration into three separate flows.
The first flow will create a normal HTTP connection to which the Sender Application will upload the JSON document. It will take the JSON document and convert each entry into a message using the batch module (note: this is only available in the Enterprise edition - for the CE version you'll have to code this logic yourself). Next, take this message and put them in a separate queue. Return the unique ID of this message as a JSON response back to the Sender Application.
Your second flow is listening on this queue and whenever a message arrives, it connects to the Device Controller and gets the response. The response is then written to another queue.
Your third and final flow listens on this results queue, takes each message on this queue and converts it to JSON/XML. It then has a HTTP connector where it can be queried for results for each command.
In the above setup, your Sender Application can drop a large JSON file of commands to be executed; for each command, a unique ID will be returned to the Sender Application.
It will then query the result endpoint (what your last flow exposes) and send it the message ID. The result endpoint will then check the status of this request and respond with the appropriate code.
Here is an example of how this would work (from the point of view of the Sender Application):
I is the input to your flow, O is the result sent.
Step 1 - send a request for commands to be executed:
I: Sender Application > http://localhost:8080/input-commands?device=1&command=Y
O: <command><req-status>OK</req-status><id>1234-123</id></command>
Step 2 - Query results:
I: Sender Application > http://localhost:8080/result?id=1234-123
O: <command><id>1234-123</id><result>0</result></command>

How to receive webhook signal from 3rd party service

I'm using a SaaS for my AWS instance monitoring and Mandrill for email sending/campaigns.
I had created a simple chart with Zapier but I'd rather like to host it myself. So my question is:
How can I receive a webhook signal from Mandrill and then send it to Datadog from my server? Then again I guess hosting this script right on the same server I'm monitoring would be a terrible idea...
Basically I don't know how to "receive the webhook" so I can report it back to my Datadog service agent so it gets updated on their website.
I get how to actually report the data to Datadog as explained here http://docs.datadoghq.com/api/ but I just don't have a clue how to host a listener for web hooks?
Programming language isn't important, I don't have a preference for that case.
Here you can find how to add a new webhook to your mandrill account: https://mandrillapp.com/api/docs/webhooks.php.html#method=add
tha main thing here is this:
$url = 'http://example/webhook-url';
this is your webhook URL what will process the data sent by mandrill and forward the information to Datadog.
and this is a description about what mandrill will send to your webhook URL: http://help.mandrill.com/entries/21738186-Introduction-to-Webhooks
a listener for webhooks is nothing else then a website/app which triggers an action if a request comes in. Usually you keep it secret or secure it with (http basic) authentication. E.g. create a website called http://yourdomain.com/hooklistener.php. You can then call it with HTTP POST or GET and pass some data like hooklistener.php?event=triggerDataDog or with POST and send data along with the body. You then run a script or anything you want to process that event.
A "listener" is just any URL that you host where you can receive data that is posted to it. Keep in mind, since you mentioned Zapier, you can set up a trigger that receives the webhook data - in this case the listener URL is provided by Zapier, and you can then send that data into any application (or even post to another webhook). Using Zapier is nice because it doesn't require you to write the listener code that receives the hook data and does something with it.