You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In larger scale deployment, it might be desirable to decouple communication from business logic, and use queueing/streaming to exchange messages between communication and business logic layers. Current model makes it possible, but with the cost of implementing asynchronous logic in implementation of *EventHandler interface.
I propose to add the asynchronous logic of handling requests sent to the server in the library itself. Let's consider example: interface ServerCoreEventHandler has method handleBootNotificationRequest, which returns BootNotificationConfirmation. Library code expects the method to return result synchronously. SimplePromiseFulfiller assumes confirmation is always returned, and completes promise passing it the confirmation. To allow asynchronous execution, handleBootNotificationRequest will return null, indicating that result is not available immediately. In such case, SimplePromiseFulfiller will not complete the promise. Internally, server will store the promise keyed by session id and message id. Once client library (client means not the client of OCPP server, but library which utilizes Java-OCA-OCPP) completes handling the request in whatever way suits its needs, it calls new method JSONServer.completeRequestAsync(UUID sessionIndex, String id, Confirmation confirmation). This method will find stored promise by (sessionIndex, id) key, complete it and remove from storage.
Please let me know if this enhancement is a good idea. Once you confirm, I will start implementing it.
The text was updated successfully, but these errors were encountered:
In larger scale deployment, it might be desirable to decouple communication from business logic, and use queueing/streaming to exchange messages between communication and business logic layers. Current model makes it possible, but with the cost of implementing asynchronous logic in implementation of
*EventHandler
interface.I propose to add the asynchronous logic of handling requests sent to the server in the library itself. Let's consider example: interface
ServerCoreEventHandler
has methodhandleBootNotificationRequest
, which returnsBootNotificationConfirmation
. Library code expects the method to return result synchronously.SimplePromiseFulfiller
assumes confirmation is always returned, and completes promise passing it the confirmation. To allow asynchronous execution,handleBootNotificationRequest
will return null, indicating that result is not available immediately. In such case,SimplePromiseFulfiller
will not complete the promise. Internally, server will store the promise keyed by session id and message id. Once client library (client means not the client of OCPP server, but library which utilizes Java-OCA-OCPP) completes handling the request in whatever way suits its needs, it calls new methodJSONServer.completeRequestAsync(UUID sessionIndex, String id, Confirmation confirmation)
. This method will find stored promise by(sessionIndex, id)
key, complete it and remove from storage.Please let me know if this enhancement is a good idea. Once you confirm, I will start implementing it.
The text was updated successfully, but these errors were encountered: