vertx.eventBus().registerDefaultCodec(CheckHealthCommand.class, new CheckHealthCommandCodec());
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/7ea5aa20-aa6a-45c6-9ad9-9d0b639345ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
public class LocalMessageCodec implements MessageCodec<Message, Message> {
@Override
public void encodeToWire(Buffer buffer, Message obj) {
throw new UnsupportedOperationException(obj.toString());
}
@Override
public Message decodeFromWire(int pos, Buffer buffer) {
throw new UnsupportedOperationException(buffer.toString());
}
@Override
public Message transform(Message command) {
return command;
}
@Override
public String name() {
return Message.class.getSimpleName();
}
@Override
public byte systemCodecID() {
return -1;
}
}
MessageConsumer<T> consumer = vertx.eventBus()
.localConsumer(type.getName(),
private final DeliveryOptions options = new DeliveryOptions()
.setCodecName(Message.class.getSimpleName())
vertx.eventBus().publish(event.getClass().getName(), event, options);
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/6559c8e8-27be-4572-b721-0530005d2e6e%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/1edf87e5-27d3-49b1-8d95-17921717a643%40googlegroups.com.
@Log
@RequiredArgsConstructor(staticName = "of")
public class GenericCodec<T extends Object> implements MessageCodec<T, T> {
private final Class<T> entityClass;
private final String codecName;
@Override
public void encodeToWire(Buffer buffer, T s) {
ObjectOutput out = null;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
out = new ObjectOutputStream(bos);
out.writeObject(s);
out.flush();
buffer.appendInt(bos.size());
buffer.appendBytes(bos.toByteArray());
} catch (IOException ex) {
log.log(Level.SEVERE, "Encode problem", ex);
} finally {
try {
bos.close();
} catch (IOException ex) {
log.log(Level.SEVERE, "Close encode problem", ex);
}
}
}
@Override
public T decodeFromWire(int pos, Buffer buffer) {
// Length of JSON
int length = buffer.getInt(pos);
// Jump 4 because getInt() == 4 bytes
ByteArrayInputStream bis = new ByteArrayInputStream(buffer.getBytes(pos += 4, pos += length));
ObjectInput in = null;
T u = null;
try {
in = new ObjectInputStream(bis);
u = (T) in.readObject();
} catch (Exception ex) {
log.log(Level.SEVERE, "Decode problem", ex);
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException ex) {
log.log(Level.SEVERE, "Close decode problem", ex);
}
}
return u;
}
@Override
public T transform(T t) {
return t;
}
@Override
public String name() {
return this.codecName;
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/081dfab3-ceb5-49aa-bcaa-d20538e9bf2e%40googlegroups.com.