use of org.apache.ignite.internal.network.serialization.DescriptorRegistry in project ignite-3 by apache.
the class DefaultMessagingService method onMessage.
/**
* Handles an incoming messages.
*
* @param obj Incoming message wrapper.
*/
private void onMessage(InNetworkObject obj) {
if (isInNetworkThread()) {
inboundService.submit(() -> onMessage(obj));
return;
}
NetworkMessage msg = obj.message();
DescriptorRegistry registry = obj.registry();
String consistentId = obj.consistentId();
try {
msg.unmarshal(marshaller, registry);
} catch (Exception e) {
throw new IgniteException("Failed to unmarshal message: " + e.getMessage(), e);
}
if (msg instanceof InvokeResponse) {
InvokeResponse response = (InvokeResponse) msg;
onInvokeResponse(response.message(), response.correlationId());
return;
}
Long correlationId = null;
NetworkMessage message = msg;
if (msg instanceof InvokeRequest) {
// Unwrap invocation request
InvokeRequest messageWithCorrelation = (InvokeRequest) msg;
correlationId = messageWithCorrelation.correlationId();
message = messageWithCorrelation.message();
}
ClusterNode sender = topologyService.getByConsistentId(consistentId);
NetworkAddress senderAddress;
if (sender != null) {
senderAddress = sender.address();
} else {
// TODO: IGNITE-16373 Use fake address if sender is not in cluster yet. For the response, consistentId from this address will
// be used
senderAddress = new NetworkAddress(UNKNOWN_HOST, UNKNOWN_HOST_PORT, consistentId);
}
for (NetworkMessageHandler networkMessageHandler : getMessageHandlers(message.groupType())) {
// TODO: IGNITE-16373 We should pass ClusterNode and not the address
networkMessageHandler.onReceived(message, senderAddress, correlationId);
}
}
Aggregations