use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class AbstractSerializerTest method errorMessageTest.
@Test
public void errorMessageTest() throws IOException, ClassNotFoundException {
ErrorData data = new ErrorData(ErrorType.AUTH_FAILED, FLOW_NAME, "Bad credentials");
System.out.println(data);
ErrorMessage info = new ErrorMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
info.setData(data);
serialize(info);
Message message = (Message) deserialize();
assertTrue(message instanceof ErrorMessage);
ErrorMessage resultInfo = (ErrorMessage) message;
assertTrue(resultInfo.getData() != null);
ErrorData resultData = resultInfo.getData();
System.out.println(resultData);
assertEquals(data, resultData);
assertEquals(data.hashCode(), resultData.hashCode());
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class AbstractSerializerTest method flowPathResponseTest.
@Test
public void flowPathResponseTest() throws IOException, ClassNotFoundException {
FlowPathResponse data = new FlowPathResponse(path);
System.out.println(data);
InfoMessage info = new InfoMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
serialize(info);
Message message = (Message) deserialize();
assertTrue(message instanceof InfoMessage);
InfoMessage resultInfo = (InfoMessage) message;
assertTrue(resultInfo.getData() instanceof FlowPathResponse);
FlowPathResponse resultData = (FlowPathResponse) resultInfo.getData();
System.out.println(resultData);
assertEquals(data, resultData);
assertEquals(data.hashCode(), resultData.hashCode());
assertEquals(path.hashCode(), resultData.getPayload().hashCode());
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class KafkaMessageConsumer method receive.
/**
* Receives messages from WorkFlowManager queue.
*
* @param record the message object instance
*/
@KafkaListener(id = "northbound-listener", topics = Topic.NORTHBOUND)
public void receive(final String record) {
try {
logger.trace("message received");
Message message = MAPPER.readValue(record, Message.class);
if (Destination.NORTHBOUND.equals(message.getDestination())) {
logger.debug("message received: {}", record);
messages.put(message.getCorrelationId(), message);
} else {
logger.trace("Skip message: {}", message);
}
} catch (IOException exception) {
logger.error("Could not deserialize message: {}", record, exception);
}
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class FlowServiceImpl method updateFlow.
/**
* {@inheritDoc}
*/
@Override
public FlowPayload updateFlow(final FlowPayload flow, final String correlationId) {
LOGGER.debug("Update flow: {}={}", CORRELATION_ID, correlationId);
FlowUpdateRequest data = new FlowUpdateRequest(Converter.buildFlowByFlowPayload(flow));
CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
messageConsumer.clear();
messageProducer.send(topic, request);
Message message = (Message) messageConsumer.poll(correlationId);
FlowResponse response = (FlowResponse) validateInfoMessage(request, message, correlationId);
return Converter.buildFlowPayloadByFlow(response.getPayload());
}
use of org.openkilda.messaging.Message in project open-kilda by telstra.
the class FlowServiceImpl method pathFlow.
/**
* {@inheritDoc}
*/
@Override
public FlowPathPayload pathFlow(final String id, final String correlationId) {
LOGGER.debug("Flow path: {}={}", CORRELATION_ID, correlationId);
FlowPathRequest data = new FlowPathRequest(new FlowIdStatusPayload(id, null));
CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
messageConsumer.clear();
messageProducer.send(topic, request);
Message message = (Message) messageConsumer.poll(correlationId);
FlowPathResponse response = (FlowPathResponse) validateInfoMessage(request, message, correlationId);
return Converter.buildFlowPathPayloadByFlowPath(id, response.getPayload());
}
Aggregations