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.
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.
WebSockets are the best solution. check the implementation in java in the server side
Related
I have to build a server to which I make requests using Unity for a mobile game.
I was advised to stay away from using REST for the server.
I want to be able to, in the client, make GET and POST requests via endpoints like "/players".
My question here is: which programming language and programs do you recommend me to start with to build a server to which clients can communicate with, in this case?
I've been using NodeJS to write servers for my programs and I've found it really good for a couple of reasons:
1) It is easy to understand the syntax (JS) if you've been using UnityScript or C# in the past.
2) There is a free download from the Asset Store that helps you parse and send data from a NodeJS server.
I am currently working on a Client - Server Chat Application written in Kotlin. The Communication is over Sockets. Now i want to code a Web Application for the Client. Right now I am not sure where to start and what Programming Language to use or which frameworks. I've tested a few frameworks like vaadin and jsf but i can't figure out what to use. And the Application should have a Login screen and a Main Page like the Whatsapp web client. I have decent Experience in Java/Kotlin and JavaFX/TornadoFX.
Try ConnectyCube. They provide server backend and have Kotlin SDK, should fit your needs. Its possible to create free account for small apps.
I'm new in android and i want to know if there is some server / web service online that o can use to update and communicate with my app?
example: I have the app "message" in 5 phones so I want to communicate with all of them, if the phone 1 send a message all device must receive notification.
There is something that I can use maybe free?
You have many options to accomplish this goal, and most provide some free level of support.
In general if you want to "push" notifications to android devices, you can either directly use or use some provider that uses Google Cloud Messaging.
Using this approach directly means you need some web server to send request to, which will then forward a request to Google, which will then forward your "message" to the devices you want to reach. There are many options for free hosting of (smallish) web services. IBM's BlueMix and Heroku come to mind. So if your are comfortable writing web apps, this might be a good choice. I have used both (for Ruby on Rails backends to mobile apps) and found both very good, but am currently using Bluemix.
I believe Bluemix along with Parse also offer mobile data storage and easy access to Push notifications to both Android and iOS. I am currently using Bluemix via Ruby on Rails and pushing messages directly to devices via GCM and don't have much experience with those particular offerings.
We are in the need of "push notification" mechanism, to desktop clients written in java, and mobile clients such as android, ios and windowsphone8. I came across "server side events" which fits very well, as we only need unidirectional communication from the server to the clients, so websockets are overkill for this scenario. We are currently using polling as fallback but we want to avoid this as much as possible.
As I understand it the server needs to be some kind of "publish subscribe" module but I'm not sure if "spring framework" provides any helping hand here or if there are other frameworks helping out with the pipelining. I have read about redis being a good candidate for publish subscribe module. However what framework / component to use to connected a java desktop client to this publish subscribe module is what I want help with.
There are a bunch of technologies / framework out there html 5 websockets, socket.io and so on but these only work for web, i.e browser clients.. I'm looking at java.net.ServerSockets (not used it before) but slightly unsure if that is the best approach. We will have a seperate "service module" running on the same desktop as the java desktop client, This service will handle a push notifications.
Sounds like you could use Java Messaging Service (JMS)
Spring's support for JMS
http://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/jms.html
J2EE JMS
http://docs.oracle.com/javaee/1.3/jms/tutorial/1_3_1-fcs/doc/overview.html#1027335
Also, check out these similar questions --
how to notify java desktop clients about changes from server?
Push notifications to various devices through a common code
I'm interested in having a desktop application send messages to a web app. Specifically, the desktop app, written in Java, needs to send messages to a Javascript function that will be running in a browser. The messages only need to be sent one way. Also, both programs will be running on the same local machine. I can set up a local development server if necessary.
I'm new to networking and web development and I have no idea how to approach this problem. Can anyone offer any suggestions?
I think the appropriate way to do that (if not the only way) would be to go through a server both apps talks to
The enterprise architecture way I recommend you do is:
Put the common information into a webservice.
The website sends information, possibly via ajax or by navigating to a different URL or doing a form POST to the webservice.
The desktop app will start up and will subscribe to the webservice. The webservice will notify the desktop app once it has an update. (note that the desktop app, might need to poll for updates).
That approach is how services such as flikr, twitter etc use.
The light weight (ie smaller architecture) way of hacking this is to make your website have an RSS feed that your desktop app subscribes to. The desktop app gets updated via the RSS feed.
That approach is how services such as news websites will send updates to readers. See google reader as an example RSS client. RSS has an adavantage of supporting generic rss consumers like MS outlook or google reader from the start, where as webservices are likely to be more flexible and cleaner in the long run.
why does the desktop app need to talk to javascript? What is it you are actually trying to do? Send or receive data to or from a database? Run some business logic on the web app? These things are typically done from a desktop app to a website using soap or rest.
is the browser embedded somehow in the desktop app? Or could is it just running as a separate process? It seems like audio processing should really run in the desktop app.
However, assuming that the browser is running as a separate app, you should be able to send messages to the browser through the query string. The desktop app could fire up the browser, point it to a url and pass some parameters to it. THen javascript can process those parameters. Google whether jquery can process query string parameters.
Embed a simple container like jetty then use Jersey or a Simple Servlet