use of com.hazelcast.topic.impl.DataAwareMessage in project hazelcast by hazelcast.
the class TopicAddMessageListenerMessageTask method onMessage.
@Override
public void onMessage(Message message) {
if (!endpoint.isAlive()) {
return;
}
if (!(message instanceof DataAwareMessage)) {
throw new IllegalArgumentException("Expecting: DataAwareMessage, Found: " + message.getClass().getSimpleName());
}
DataAwareMessage dataAwareMessage = (DataAwareMessage) message;
Data messageData = dataAwareMessage.getMessageData();
String publisherUuid = message.getPublishingMember().getUuid();
ClientMessage eventMessage = TopicAddMessageListenerCodec.encodeTopicEvent(messageData, message.getPublishTime(), publisherUuid);
boolean isMultithreaded = nodeEngine.getConfig().getTopicConfig(parameters.name).isMultiThreadingEnabled();
if (isMultithreaded) {
int key = rand.nextInt();
int partitionId = hashToIndex(key, nodeEngine.getPartitionService().getPartitionCount());
eventMessage.setPartitionId(partitionId);
sendClientMessage(eventMessage);
} else {
sendClientMessage(partitionKey, eventMessage);
}
}
Aggregations