Well, there is the dojox/socket
module which allows you to any WebSocket or Comet (= HTTP long polling) solution.
An alternative is the CometD project, this is a solution that uses long polling and allows you to communicate with Java applications (using the CometD Java library) and JavaScript applications (using the CometD Dojo library).
However, it is not out of the box with Dojo but is a separate project (the JavaScript lib was included in older versions though).
Your code setup will change, obviously. First you need to be able to run the CometD Java service, and then you can use ServerSession
to publish data or ClientSession
to subscribe at the Java side. Going into detail would be too broad, but you should probably read the reference guide.