File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Kind a push notification? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Kind a push notification?" Watch "Kind a push notification?" New topic
Author

Kind a push notification?

Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 506
We have server that hosts our web application (written in Java). And we have one windows desktop application in C#. Now this desktop app app fetches data through web services from web app server. Now we need a way to make a call from server to this desktop app and pass some data.

For example, Whenever there is a new image file uploaded on server. Server needs to notify the desktop app that there is new file. Please download it. How can I do it?
Roger Sterling
Ranch Hand

Joined: Apr 06, 2012
Posts: 426

When desktop client starts, have it register a callback with the server.

For an example, is this no different than Microsoft Exchange server telling Microsoft Outlook that new mail has arrived in the user's mailbox ?
Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 506
Roger Sterling wrote:When desktop client starts, have it register a callback with the server.

For an example, is this no different than Microsoft Exchange server telling Microsoft Outlook that new mail has arrived in the user's mailbox ?


In my case client is in C# and server is in Java (Spring framework). How do I implement "call back" functionality?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41073
    
  43
Callbacks won't work in all cases, though - if the client's IP is NAT'ed somewhere along the way, all bets are off. Even if there's a unique IP, the firewall likely won't allow incoming connections.

Unless there's a persistent connection, of course, but if that's feasible depends on how many clients you expect. And since you're calling it "push notification", I'm guessing that you don't want one.


Ping & DNS - my free Android networking tools app
Roger Sterling
Ranch Hand

Joined: Apr 06, 2012
Posts: 426

Saurabh Pillai wrote:
Roger Sterling wrote:When desktop client starts, have it register a callback with the server.

For an example, is this no different than Microsoft Exchange server telling Microsoft Outlook that new mail has arrived in the user's mailbox ?


In my case client is in C# and server is in Java (Spring framework). How do I implement "call back" functionality?



I guess you would do this by following the tutorial...


It does not matter that one is written in one language and the other is written in a different language. Do you have a coach or mentor on your site?
Roger Sterling
Ranch Hand

Joined: Apr 06, 2012
Posts: 426

Ulf Dittmer wrote:Callbacks won't work in all cases, though - if the client's IP is NAT'ed somewhere along the way, all bets are off. Even if there's a unique IP, the firewall likely won't allow incoming connections.

Unless there's a persistent connection, of course, but if that's feasible depends on how many clients you expect. And since you're calling it "push notification", I'm guessing that you don't want one.


Firewall rules are meant to be broken... (ie. changed by the System Administrator).

Persistence is not needed. Callbacks are asynchronous and do not require constant connection to the server.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41073
    
  43
I doubt the sys admins will be happy to change firewall settings just so such a scheme would work, and justifiably so IMO. It seems more realistic to constrain it to inside of the firewall, and possibly implement an additional pull option if it needs to work outside of it as well.
Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 506
Ulf Dittmer wrote:Callbacks won't work in all cases, though - if the client's IP is NAT'ed somewhere along the way, all bets are off. Even if there's a unique IP, the firewall likely won't allow incoming connections.

Unless there's a persistent connection, of course, but if that's feasible depends on how many clients you expect. And since you're calling it "push notification", I'm guessing that you don't want one.


This is what my application is. We have a desktop app written in C# (Somebody else manages it. I work on server side which is Java(Spring Framework)). Desktop program is a Player which plays the playlist (list of images and videos). Desktop app calls the server to down the playlist through web service. All is fine so far. Now if somebody changes the playlist contents, server needs to send the notification to the player that contents has changed and please update your playlist. So client calls the server again and update the playlist (by downloading the new contents). This is the full cycle. The problem is how does server inform the client?

And my company is planning to sell the player as a product so we won't have access to customer's WIFI router, obviously. I am wondering how does any web chat works (like gmail chat)? It works on any network and it pushes the message to all devices which have gmail talk open like browser or phone.

Thank you for your time.
Roger Sterling
Ranch Hand

Joined: Apr 06, 2012
Posts: 426

Ulf Dittmer wrote:I doubt the sys admins will be happy to change firewall settings just so such a scheme would work, and justifiably so IMO. It seems more realistic to constrain it to inside of the firewall, and possibly implement an additional pull option if it needs to work outside of it as well.


In my experience, the system admins will do what the business leaders tell them to. And if this is a valid business requirement, then why shouldn't they ?

Ulf - so you are saying that people shouldn't use Microsoft Outlook ? What gives ? The proposal does nothing more or less than the network transaction between MS Exchange and MS Outlook .
Roger Sterling
Ranch Hand

Joined: Apr 06, 2012
Posts: 426

Saurabh Pillai wrote:
Ulf Dittmer wrote:Callbacks won't work in all cases, though - if the client's IP is NAT'ed somewhere along the way, all bets are off. Even if there's a unique IP, the firewall likely won't allow incoming connections.

Unless there's a persistent connection, of course, but if that's feasible depends on how many clients you expect. And since you're calling it "push notification", I'm guessing that you don't want one.


This is what my application is. We have a desktop app written in C# (Somebody else manages it. I work on server side which is Java(Spring Framework)). Desktop program is a Player which plays the playlist (list of images and videos). Desktop app calls the server to down the playlist through web service. All is fine so far. Now if somebody changes the playlist contents, server needs to send the notification to the player that contents has changed and please update your playlist. So client calls the server again and update the playlist (by downloading the new contents). This is the full cycle. The problem is how does server inform the client?

And my company is planning to sell the player as a product so we won't have access to customer's WIFI router, obviously. I am wondering how does any web chat works (like gmail chat)? It works on any network and it pushes the message to all devices which have gmail talk open like browser or phone.

Thank you for your time.


Asynchronous callbacks can use already open ports, or you can have installation instructions that tell the end user which ports need to be open. I'm not sure why Ulf thinks this is so illegal. I could list a thousand applications that do this now. Apple iTunes being one.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41073
    
  43
I said nothing of the kind. Don't distort my words.
Roger Sterling
Ranch Hand

Joined: Apr 06, 2012
Posts: 426

In Windows 8.1 , the Windows Firewall automatically detects which ports you are trying to use, and if they are not open, prompts the user for permission to open them. You may still have to provide release notes about router port configurations that may be needed by your product.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41073
    
  43
I advise against any design that requires firewalls to be opened up, whether they be corporate or private. The security implications are clear, but in addition to that for the pragmatic reason of not scaring your customers - who I assume you want to pay for your product.

You haven't said why it's so important that clients be notified right when new files are available, though, as opposed to a minute or so later, when a client-poll solution could reasonable be expected to learn about it.
Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 506
Ulf Dittmer wrote:You haven't said why it's so important that clients be notified right when new files are available, though, as opposed to a minute or so later, when a client-poll solution could reasonable be expected to learn about it.


As I said earlier, when playlist contents change, server needs to notify the client(player) about the same, so that player can download the changed contents. Client-poll is you call server every minute,right? Isn't it a burden on server? whereas if you can push to clients, it is event based. And does not put load on the server. Now assume that we have 100 clients running, they would be calling server every minute in case of poll. This is why I am looking for PUSH notification kind solution.

I am wondering can not I implement something that Gmail chat or Skype uses? Thank you.


@Roger I am also looking at Async callback. I have two speed breaker right now. One is client is in C# and server is in Java. How to make them talk? I have little knowledge about how to implement it Java and C#. Thank you.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41073
    
  43
Saurabh Pillai wrote:Now assume that we have 100 clients running, they would be calling server every minute in case of poll.

Is 100 clients a realistic number? That's a very small number, 100 requests per minute would not begin to tax the server.
Roger Sterling
Ranch Hand

Joined: Apr 06, 2012
Posts: 426

A byte is a byte. If C# writes 0x37 to that byte and Java reads 0x37 from that byte, what difference does the implementation language make ?
 
 
subject: Kind a push notification?
 
Similar Threads
Can a Android app sync data with a desktop application?
ways to deploy only the changes done in GWT web app something like a upgrade patch
Java application inside tomcat?
integration options for desktop applications
how to setup multile instances specific parameters of a same web application ?