use of com.hazelcast.spi.impl.eventservice.impl.operations.SendEventOperation in project hazelcast by hazelcast.
the class EventServiceImpl method sendEvent.
private void sendEvent(Address subscriber, EventEnvelope eventEnvelope, int orderKey) {
final String serviceName = eventEnvelope.getServiceName();
final EventServiceSegment segment = getSegment(serviceName, true);
boolean sync = segment.incrementPublish() % eventSyncFrequency == 0;
if (sync) {
SendEventOperation op = new SendEventOperation(eventEnvelope, orderKey);
Future f = nodeEngine.getOperationService().createInvocationBuilder(serviceName, op, subscriber).setTryCount(SEND_RETRY_COUNT).invoke();
try {
f.get(SEND_EVENT_TIMEOUT_SECONDS, TimeUnit.SECONDS);
} catch (Exception e) {
syncDeliveryFailureCount.inc();
if (logger.isFinestEnabled()) {
logger.finest("Sync event delivery failed. Event: " + eventEnvelope, e);
}
}
} else {
Packet packet = new Packet(serializationService.toBytes(eventEnvelope), orderKey).setPacketType(Packet.Type.EVENT);
if (!nodeEngine.getNode().getConnectionManager().transmit(packet, subscriber)) {
if (nodeEngine.isRunning()) {
logFailure("Failed to send event packet to: %s , connection might not alive.", subscriber);
}
}
}
}
Aggregations