The class that reads the STOMP message is in Stompdecoder, Org.springframework.messaging.simp.stomp.StompDecoder.
Jackson turned the JSON object into the following steps:
1. Resolveargument in Org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolverComposite class ( Methodparameter parameter, message<?> Message) method, returns an object
2. Resolveargument in Org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver class ( Methodparameter parameter, message<?> message) method, Object target = this.converter.fromMessage (message, Targetclass);
3. Call the frommessage of the Org.springframework.messaging.converter.CompositeMessageConverter class (Message<?> Message, Class<?> Targetclass) method, traverse all converters in this class, find the appropriate result and return.
4. Call Frommessage in the Org.springframework.messaging.converter.AbstractMessageConverter class (Message<?> Message, Class<?> targetclass) convertfrominternal (message, targetclass);
5, convertfrominternal (message, targetclass); method is instantiated in Org.springframework.messaging.converter.MappingJackson2MessageConverter (PS: You can also use other convert, as long as spring supports it):
Public Object convertfrominternal (Message<? > Message, class< ?> Targetclass) { Javatype javatype = This.objectMapper.constructType (targetclass); Object payload = Message.getpayload ();//Here you can see the fetch message byte stream try { if (payload instanceof byte[]) { return This.objectMapper.readValue ((byte[]) payload, javatype);//This is the core of the conversion } else { return This.objectMapper.readValue (String) payload, javatype);} } catch (IOException ex) { throw new messageconversionexception (message, "Could not read JSON:" + ex.getmessage (), ex) ; } }
6. Starting from here, call the Fasterxml.jackson package to bind the data.
By default, JSON is bound to map, and if there is an object, the map is converted to an object.
Stomp and Jackson