longkerdandy / mithqtt

MQTT Message Broker with Scalability written in Java
https://mithqtt.readme.io/
Apache License 2.0
41 stars 24 forks source link

About mqtt message serialize & deserialize to json data return empty #58

Closed pysjp closed 7 years ago

pysjp commented 7 years ago

the value of message is filled by fromMqttMessage,but when JSONs.Mapper.writeValueAsBytes,its return empty json data.

the trace logs as follows:

2016-10-07 16:19:53.061 [nioEventLoopGroup-6-1] TRACE c.g.l.m.c.n.NATSClusterImpl sendToApplication 135 - sendToApplication Message[fixedHeader=MqttFixedHeader[messageType=SUBSCRIBE, dup=false, qos=AT_LEAST_ONCE, retain=false, remainingLength=9], additionalHeader=MqttAdditionalHeader[version=MQTT_3_1, clientId=1234, userName=null, brokerId=1], variableHeader=MqttPacketIdVariableHeader[packetId=1], payload=] 2016-10-07 16:19:53.062 [nioEventLoopGroup-6-1] TRACE c.g.l.m.c.n.NATSClusterImpl sendToApplication 136 - sendToApplication {} 2016-10-07 16:19:53.062 [nioEventLoopGroup-6-1] TRACE c.g.l.m.c.n.NATSClusterImpl sendToApplication 137 - sendToApplication [123, 125]

longkerdandy commented 7 years ago

Hi

Can you give me more information on this issue. It seems to me, you are tring to read message from NATS and failed somehow? And you believed there is a problem in serializing or deserializing json, right?

From the logs, there are no errors and I can't identify the problem. I'll make a quick test ASAP. Mean while more information will be appreciated.

pysjp commented 7 years ago

thanks for your reply,When I add following option in JSONs.java,it can be serialized to json corrected with right value. Mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); BTW,when the message which type is subscrble is serializing to json,the field of payload is missing. I can not find the way to fixed it. hope for your reply

longkerdandy commented 7 years ago

Bug fixes commit d579c22

pysjp commented 7 years ago

thanks,it works well now