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
The JsonViewSerializer should be registered as a MessageConverter for Spring-Messaging serialization.
The team I work with implemented similar serialization logic several years back to allow clients to specify requested properties to reduce bandwidth usage. This works similar to the Squiggly Filter library in that it obtains the requested properties from the HttpServletRequest object itself, which is okay when such an object exists but requires some extra tricks if it doesn't, such as when working with WebSockets. The technique used in JsonView comes in handy for this. We can wrap entities in configured JsonView when sending messages and register a converter to serialize them accordingly.
The one caveat to this is that spring-json-view registers an appropriate return handler with for the RequestMappingHandlerAdapter, but doesn't do a similar MessageConverter registration to convert Message entities. We currently do this registration manually through the configureMessageConverters method of our AbstractWebSocketMessageBrokerConfigurer implementation.
The simple gist of our implementation using Spring 4.3.14 is as follows:
It would be helpful for the library to implement the message converter and to automatically register this converter for the user or to create a small separate library to do so in order to prevent unwanted dependencies on spring-messaging.
Although our implementation is not yet using it, the JsonResult functionality might also be implemented via the converter's canConvertTo method.
Lastly, thank you for creating and sharing this project! This is very helpful for the application that we're working on.
The text was updated successfully, but these errors were encountered:
The
JsonViewSerializer
should be registered as aMessageConverter
for Spring-Messaging serialization.The team I work with implemented similar serialization logic several years back to allow clients to specify requested properties to reduce bandwidth usage. This works similar to the Squiggly Filter library in that it obtains the requested properties from the
HttpServletRequest
object itself, which is okay when such an object exists but requires some extra tricks if it doesn't, such as when working with WebSockets. The technique used in JsonView comes in handy for this. We can wrap entities in configuredJsonView
when sending messages and register a converter to serialize them accordingly.The one caveat to this is that
spring-json-view
registers an appropriate return handler with for theRequestMappingHandlerAdapter
, but doesn't do a similarMessageConverter
registration to convertMessage
entities. We currently do this registration manually through theconfigureMessageConverters
method of ourAbstractWebSocketMessageBrokerConfigurer
implementation.The simple gist of our implementation using Spring 4.3.14 is as follows:
It would be helpful for the library to implement the message converter and to automatically register this converter for the user or to create a small separate library to do so in order to prevent unwanted dependencies on
spring-messaging
.Although our implementation is not yet using it, the
JsonResult
functionality might also be implemented via the converter'scanConvertTo
method.Lastly, thank you for creating and sharing this project! This is very helpful for the application that we're working on.
The text was updated successfully, but these errors were encountered: