javascript - How to handle CQRS from a client-side perspective -
my company planning utilize cqrs architecture on our back-end client-side developer i'm bit confused how consume request. here methods came with, none beingness ideal point of view:
the server waits until queue gets processed , gives needed info in response. (sounds pretty poor approach performance point of view); the client makes request , gets "202 accepted" 1 time request added queue, client uses interval scheme pool until gets necessary info back-end (i'm not big fan of doing x http request every second); web sockets ... seems perfect solution server able force info client 1 time processed (i'm bit concerned having thousands of sockets opened around entire app).so question is: best approach problem? (not 1 of above)
well, depends on plan in ui.
if have spa , understanding of events , subscriptions in javascript, single websocket connection seems natural option. thousands of websocket connections not problem in server if connections idle of time, , server asynchronous (to avoid thread starvation). then... why want rest interface? can send requests through websocket correlation id , wait response same correlation id know when done, way avoid overhead of creating new connections per each request.
if more comfortable ajax , want utilize rest, can utilize asynchronous approach, need pool till http 303 see other. not perfect, improve opening websocket sake of operation.
blocking connection till there response bad approach. network cannot considered reliable, if connection cuts, browser needs know how find out result o fthe operation.
javascript rest websocket client-server cqrs
No comments:
Post a Comment