org.yamcs.artemis.EventTupleTranslator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yamcs-artemis Show documentation
Show all versions of yamcs-artemis Show documentation
Yamcs Artemis senders/receivers
package org.yamcs.artemis;
import org.apache.activemq.artemis.api.core.client.ClientMessage;
import org.yamcs.StandardTupleDefinitions;
import org.yamcs.api.artemis.ArtemisApiException;
import org.yamcs.api.artemis.Protocol;
import org.yamcs.protobuf.Yamcs.Event;
import org.yamcs.yarch.Tuple;
import org.yamcs.yarch.TupleDefinition;
public class EventTupleTranslator implements TupleTranslator {
@Override
public ClientMessage buildMessage(ClientMessage msg, Tuple tuple) {
Event event = (Event) tuple.getColumn("body");
Protocol.encode(msg, event);
return msg;
}
@Override
public Tuple buildTuple(ClientMessage msg) {
TupleDefinition tdef = StandardTupleDefinitions.EVENT;
try {
Event event = (Event) Protocol.decode(msg, Event.newBuilder());
return new Tuple(tdef, new Object[] { event.getGenerationTime(),
event.getSource(), event.getSeqNumber(), event });
} catch (ArtemisApiException e) {
throw new IllegalArgumentException(e.toString(), e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy