Search code examples
asynchronouswebsocketmessagingjavalin

Can two java applications talk over javelin web sockets?


I'm developing a distributed Java application that implements state machines in a master -> slave/s configuration.

I would like the master to be able to communicate with each slave asynchronously. To my novice eye, Javelin Websockets looks like a nice lightweight solution to implementing SSL connections for it.

I'm currently struggling a little with it as all of the examples I've found so far are for Javascript in a web page talking to a server. Which isn't really what I'm trying to achieve. I want a persistent connection where each Java application can asynchronously send messages either way.

Before I end up wasting time I was wondering if anyone could tell me if what I want to do is possible, and if so, are they able to point me at any code examples that use a Java application on each end, rather than a web page talking to a backend?

Thanks for any help.

Brad


Solution

  • Yes, two Java applications can talk over Javalin WebSockets. From the perspective of a web server it doesn't matter if the WebSocket client is Java based or JavaScript/Browser based. Javalin itself uses https://github.com/TooTallNate/Java-WebSocket for WebSocket integration testing.