I am seeing very weird issue when using DistributedQueue recipe in Curator.
I am thinking it might be a bug in Zookeeper or Curator but not sure yet or
may be I am doing something silly.
I am trying to queue message in Zookeeper using DistributedQueue recipe:
public void queueMessages() throws Exception {
// below is the data I am sending
DqTestHolder work = new DqTestHolder("103", "
[email protected]", "K15O");
this.queue.put(work);
}
And here is my serializer class:
public class DqTestHolderSerializer implements
QueueSerializer<DqTestHolder> {
@Override
public DqTestHolder deserialize(byte[] buffer) {
// nothing here for now
}
@Override
public byte[] serialize(DqTestHolder work) {
return work.toString().getBytes();
}
}
And here is my DqTestHolder class:
public class DqTestHolder {
private final String clientId;
private final String emailId;
private final String clientName;
public DqTestHolder(final String clientId, final String emailId,
final String clientName) {
this.clientId = clientId;
this.emailId = emailId;
this.clientName = clientName;
}
// getters here
public String toString() {
return this.clientId + "=" + this.emailId + "=" +
this.clientName;
}
}
Now after I queue above data and I go and see exhibitor, I am seeing
something like this: You see it is appending bracket ")" infront of data
and sometimes I see "(" this as well which is not what I am sending above.
)[email protected]=K15O
This is only happening when we send data with "-" in it I guess and if we
have something like this in emailId - "[email protected]" then I don't see any
bracket and it shows correctly what I am sending. So if anyone tried to get
data using getData() method, I get exactly what I see in exhibitor but not
what I have sent above.
Also when we try to use getData() method of curator to get above data from
znode, I see some wierd characters getting appended to it as well. I am
using Curator 2.8.0