Server side events - spring

I have to implement a notification callback url, which would receive some data from an external application. Once it receives the data, it should post that data in my application.I am using spring rest API for creating notification callback url. The problem that I have now is how to send that data to the browser. Any idea on how can I implement this would be much appreciated.

Related

How to perform a GET request after a POST request with web-sockets

I am currently trying to build a go API using gin for a web and mobile application. I am new to the world of WebSockets and Go so I was wondering how I would go about triggering a GET request from the client after a relevant POST request was made ie: the POST request contained the user's ID so the clients who require information regarding that user are properly updated. Currently, I have the POST and GET requests which do what I need them, but I'm a little lost about how to make the entire flow realtime using WebSockets.
I believe this example of server-sent-events should address the question. Once a POST handler has been called, send a flag to the GET endpoint via a channel and then send an event through there.

Spring client for server send events

I am using the ResponseBodyEmitter in Spring 4.2 RC1 for sending JSON object as part of the server send events. I am able to see the response in web browser. Is there any spring client for the same ?
I tried using AsyncRestTemplate, but I am getting all the response together. Ie if I am sending 3 objects one after another using ResponseBodyEmitter , using AsyncRestTemplate, I get all of them together. I would like to receive in client as and when the server sends it.
You could give a go to Reactor HTTP client if you're into async and reactive programming: https://github.com/reactor/reactor/blob/master/reactor-net/src/test/groovy/reactor/io/net/http/HttpSpec.groovy#L74.

Implement Ajax calls via XMPP messages

I have a website where users are connected with XMPP server (ejabberd). I want to replace my ajax calls with xmpp messages to reduce the load on apache server.
ie
a replace for ajax call, which works on following ideas
Send a XMPP message
Add a handler which is fired when the data for the specific ajax request is answered through a message
Is there a wrapper to do the same?
You could take a look at strophe.js.
It's a pretty powerful JavaScript library for doing XMPP in the browser.

Google Checkout handling URL Callback for order completion?

I'm developing an application that fully implements google checkout and I'm trying to figure out how to access the data sent to the API Callback URL (Specified in Integration settings) when an order has been completed?
Is the data for the completed order being sent via POST data? XML? GET? How do I go about accessing the data sent back to my web application for a completed order?
Any documentation or pointers in the right direction would be greatly appreciated!
Google Checkout will send notification callbacks to your specified callback url as an HTTP POST.
The data is in XML format in the body of the POST.
Some useful links below:
How to configure the web service to respond to callbacks: http://support.google.com/checkout/sell/bin/answer.py?hl=en-GB&answer=70647
PHP library - look at basicapiresponsehandlerdemo.php responsehandlerdemo.php which shows how to parse and respond to callbacks:
http://code.google.com/p/google-checkout-php-sample-code/

Grails: server-to-client notification

I'm building a Grails app which queries several API's across the Web. The problem is that this queries are very time consuming and it is really annoying for the user to click one button and wait so much time without nothing changes in the page.
The basic architecture of my app is, when the user clicks the button, the client side performs an Ajax request with Prototype library to the server side. The server side, then, connects to the Last.fm API and retrieve a list of events. When the server side is finished populating the list with events it sends a JSON response to the client side which allows the client side to create markers for each event on a Google map.
What I want to achieve is, instead of waiting for all the events being retrieved from the API to send the JSON response, the server side sends a JSON response as soon as it retrieve one event, allowing the client side to populate the map while other events are yet being retrieved.
Any ideas how can I implement this? I read about the concept of Ajax Push but I'm not sure if it is what I need.
Thanks for the help!
There is no way to open a listening connection on the client that your server might connect to. Instead, what you need is a connection to the server that is kept alive and can be used to receive events. This way, you could directly return the "action" request and inform the client through your persistent event connection once the last.fm request was completed.
That said, the way I would implement is using ajax keep alive.
Take a look at cometd plugin.

Resources