Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

Issue with JSON serialization #69

Closed
bhuvanalakshmi opened this issue Sep 9, 2015 · 1 comment
Closed

Issue with JSON serialization #69

bhuvanalakshmi opened this issue Sep 9, 2015 · 1 comment

Comments

@bhuvanalakshmi
Copy link

I am getting the following error when I try to publish a json msg({"test":"message"}) through crossbar.io and try to process the msg using jawampa. I also noticed that after this failure, jawampa unsubscribes to the the topic.Why is the subscription cancelled even if one message is incorrect? Please let me know if you see any issues with this code.

code to subscribe:

Observable<String> msgSubscription = wampclient.makeSubscription(topicName, String.class);
msgSubscription.subscribe(processMessageAction);

logs:

16:51:33.621 [WampClientEventLoop] DEBUG w.w.j.t.n.WampDeserializationHandler - Deserialized Wamp Message: [36,7054800803741494,1958756529312882,{},[{"test":"message"}]]
16:51:33.634 [WampClientEventLoop] ERROR ws.wamp.jawampa.WampClient -  error
java.lang.IllegalArgumentException: Can not deserialize instance of java.lang.String out of START_OBJECT token
 at [Source: N/A; line: -1, column: -1]
    at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:2774) ~[jackson-databind-2.4.4.jar:2.4.4]
    at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:2700) ~[jackson-databind-2.4.4.jar:2.4.4]
    at ws.wamp.jawampa.WampClient$3.call(WampClient.java:389) [classes/:na]
    at ws.wamp.jawampa.WampClient$3.call(WampClient.java:1) [classes/:na]
    at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55) [rxjava-1.0.8.jar:1.0.8]
at ws.wamp.jawampa.client.SessionEstablishedState.onMessage(SessionEstablishedState.java:365) [classes/:na]
17:02:35.867 [WampClientEventLoop] DEBUG w.w.j.t.n.WampSerializationHandler -  Wamp Message: ws.wamp.jawampa.WampMessages$UnsubscribeMessage@41df3cc2
@Matthias247
Copy link
Owner

I think the problem is that you publish an object ({test: "message"}), but try to receive a String in the subscription. The types don't match, so it can't be deserialized.
I think you need to create a matching Java class that can be used to deserialize your content and pass that to makeSubscription.

The subscription is intentionally cancelled if one message is incorrect because it assumes all messages use the same format, and that only more errors will happen if it is kept alive.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants