-
Notifications
You must be signed in to change notification settings - Fork 0
MQ Communication
So far we are using RabbitMQ server. There is simple argument after this. This is the only technology supported by Spring. Our instance can be found under ptl.cloud:5671 address. Entire communication is encrypted and server will reject any message that have no TLS encryption on it.
Sample snippet to start communication with server
parameters: ConnectionParameters = ConnectionParameters(
host='ptl.cloud',
port=5671,
credentials=PlainCredentials(RABBIT_LOGIN, RABBIT_PASSWORD),
ssl=True
)
connection = BlockingConnection(parameters)More robust example can be found in pov-client-test repository, where is presented entire communication with POV server.
Communication between server and client is bi-directional, but each direction has its own unique goals
In this way we send commands and only commands to client. Each command contains information about movie to display. This will be the only source about videoId which is needed in API communication with POV Server. There is no other way except DB reading to obtain this information.
Java code presenting VideoPingMessage
@Data
@Builder
public class VideoPingMessage {
private Long videoId;
private String title;
private String description;
private List<Pair<Integer, Integer>> resolutions;
}Each message send from POV Server is encoded using Jackson which mean JSON
In this way Client is sending metrics. This is source of data for server used to display some information on main page. Each metric message should contain key and value elements. At the moment server is accepting only JSON formatted messages, as is is using Jackson encoder, what was mentioned earlier.
Java code presenting MetricMessage
@Data
public class MetricMessage {
private String key;
private Float value;
}All avalilable keys are stored in MetricKey enumeration in POV Server
public enum MetricKeys {
RPM("rpm"),
TOTAL_ROTATIONS("total_rotations"),
LAST_MINUTE_ROTATIONS("last_minute_rotations"),
DIODE_SWITCHES("diode_switches"),
FRAMES_DISPLAYED("frames_displayed"),
DATA_TRANSFERRED_TO_DISPLAY("data_transferred_to_display");
@Getter
private final String name;
MetricKeys(String name) {
this.name = name;
}
}
Server is prepared to receive messages with `value` field being `float` or other fraction enabled variable, but sending values as `1` or `343` will not break the contract as `Jackson` is able to transform it back to `float`. However representations like **E notation** - `342E-2` are not valid and sould not be used as such.
More examples on how to used communication in this dirction can be found in 'pov-client-test` implementation