Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring webapp: sending notifications to java and android clients

I recently started developing my first web application with Spring and I'm stuck with a question I could not really find an answer to. What I have is a simple Spring MVC application running in tomcat which provides data in form of JSON, XML or binary via REST. This service is consumed by two clients I developed, a simple Java desktop application and an Android app. So far the clients only got information about new data by polling. What I want now, is a way for the server to send notifications/messages to the clients when new data is available. For the Android client it would be good if the notifications could received anytime, not only when the app is currently open of course. I found lots of information for JavaScript client code but very little really useful, up-to date input about what the options for java and android clients are.

It would be really great if someone could give me some idea what would be the best way to achieve what I want (ideally something which integrates well with Spring on the server side), what protocols/libraries/frameworks to use, maybe even point me to some example or tutorial, how to implement this on server and client side.

Thanks in advance for any input.

like image 256
Thomas Thonhofer Avatar asked Aug 18 '26 10:08

Thomas Thonhofer


1 Answers

For android or mobile devices, Google Cloud Messaging is the preferred way of sending messages to applications running on devices. Example : spring gcm server side project and a sample tutorial.

For desktop apps, either poll regularly the server or run something in background like crontab or active-mq to check the messages and start the desktop app.

like image 78
Anudeep Gade Avatar answered Aug 20 '26 01:08

Anudeep Gade



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!