I'd like to synchronize the state to all the clients interested in particular entity changes. So I'd like to achieve something like:
<ul>
<li>exposing CRUD API on entity (via
and
)</li>
<li>and routing the response (of the modifying calls) to
topic</li>
</ul>
So technically, I'd be interested in ideas to mix <a href="http://projects.spring.io/spring-data-rest/">spring-data-rest</a> with <a href="https://raymondhlee.wordpress.com/2...mplement-two-way-server-client-communication/">spring websockets implementation</a> to achieve something like spring-data-websocket.
There are a two solutions coming to my mind, and in fact both would be:
<ul>
<li>spring-data-rest to expose my entities via
</li>
<li>
controllers (used for the modification calls on entities) </li>
</ul>
The
controllers would look like this:
<strong>Scenario 1:
called from
</strong>
Rules:
<ul>
<li>client request is always
</li>
<li>response is
for all the operations</li>
<li>moreover for modifying operations the
message comes as well</li>
</ul>
Technically, could be achieved, by:
<ul>
<li>calling the
controllers from the <a href="http://docs.spring.io/spring-data/rest/docs/2.0.0.M1/reference/html/events-chapter.html">spring-rest-data events</a> (namely in the
,
,
,
)</li>
</ul>
Still <strong>the solution seems quite sick to me</strong>, as I'd need to go for:
<ol>
<li>client A --
request--> Server (spring-data-rest controller)</li>
<li>Server (AfterXXXEvent in the spring-data-rest controller) --
message--> Spring
controller</li>
<li>Spring websocket controller --
message via topic--> all Clients interested in the topic</li>
<li>Server (spring-data-rest controller) --
response--> client A</li>
</ol>
<strong>Scenario 2:
independent from
</strong>
Rules:
<ul>
<li>client request is
for non-modifying operations only</li>
<li>response is
for non-modifying operations only</li>
<li>client sends
message for all the modifying operations</li>
<li>
message is sent to client for all the modifying operations only</li>
</ul>
Well, if no other ideas come up, I'd go for the later one, but still, it would be great if I could have somehow generated
methods exposed via
as well, something like spring-data-websockets and handle only the routes in my implementation.
As I feel like I'd have to manually expose (via
s) all the
methods for all my entities. And I might be too lazy for that.
Ideas?
<ul>
<li>exposing CRUD API on entity (via
Code:
HTTP/REST
Code:
websockets
<li>and routing the response (of the modifying calls) to
Code:
websockets
</ul>
So technically, I'd be interested in ideas to mix <a href="http://projects.spring.io/spring-data-rest/">spring-data-rest</a> with <a href="https://raymondhlee.wordpress.com/2...mplement-two-way-server-client-communication/">spring websockets implementation</a> to achieve something like spring-data-websocket.
There are a two solutions coming to my mind, and in fact both would be:
<ul>
<li>spring-data-rest to expose my entities via
Code:
REST/HTTP API
<li>
Code:
websocket
</ul>
The
Code:
websocket
Code:
@Controller
public class EntityAWebSocketController {
@MessageMapping("/EntityA/update")
@SendTo("/topic/EntityA/update")
public EntityA update(EntityA entityA) throws Exception {
// persist,....
return entityA;
}
}
<strong>Scenario 1:
Code:
Websocket API
Code:
REST/HTTP API
Rules:
<ul>
<li>client request is always
Code:
REST/HTTP API
<li>response is
Code:
REST/HTTP API
<li>moreover for modifying operations the
Code:
websocket
</ul>
Technically, could be achieved, by:
<ul>
<li>calling the
Code:
websocket
Code:
AfterCreateEvent
Code:
AfterSaveEvent
Code:
AfterLinkSaveEvent
Code:
AfterDeleteEvent
</ul>
Still <strong>the solution seems quite sick to me</strong>, as I'd need to go for:
<ol>
<li>client A --
Code:
HTTP
<li>Server (AfterXXXEvent in the spring-data-rest controller) --
Code:
websocket
Code:
websocket
<li>Spring websocket controller --
Code:
websocket
<li>Server (spring-data-rest controller) --
Code:
HTTP
</ol>
<strong>Scenario 2:
Code:
Websocket API
Code:
REST API
Rules:
<ul>
<li>client request is
Code:
REST/HTTP API
<li>response is
Code:
REST/HTTP API
<li>client sends
Code:
websocket
<li>
Code:
websocket
</ul>
Well, if no other ideas come up, I'd go for the later one, but still, it would be great if I could have somehow generated
Code:
C(R)UD
Code:
websockets
As I feel like I'd have to manually expose (via
Code:
*WebSocketController
Code:
CUD
Ideas?