Search in sources :

Example 1 with ReliableTopicMessage

use of com.hazelcast.topic.impl.reliable.ReliableTopicMessage in project hazelcast by hazelcast.

the class ClientReliableTopicProxy method publish.

@Override
public void publish(E payload) {
    try {
        Data data = serializationService.toData(payload);
        ReliableTopicMessage message = new ReliableTopicMessage(data, null);
        switch(overloadPolicy) {
            case ERROR:
                addOrFail(message);
                break;
            case DISCARD_OLDEST:
                addOrOverwrite(message);
                break;
            case DISCARD_NEWEST:
                ringbuffer.addAsync(message, OverflowPolicy.FAIL).get();
                break;
            case BLOCK:
                addWithBackoff(message);
                break;
            default:
                throw new IllegalArgumentException("Unknown overloadPolicy:" + overloadPolicy);
        }
    } catch (Exception e) {
        throw (RuntimeException) peel(e, null, "Failed to publish message: " + payload + " to topic:" + getName());
    }
}
Also used : ReliableTopicMessage(com.hazelcast.topic.impl.reliable.ReliableTopicMessage) Data(com.hazelcast.nio.serialization.Data) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) TopicOverloadException(com.hazelcast.topic.TopicOverloadException) DistributedObjectDestroyedException(com.hazelcast.spi.exception.DistributedObjectDestroyedException) StaleSequenceException(com.hazelcast.ringbuffer.StaleSequenceException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)1 Data (com.hazelcast.nio.serialization.Data)1 StaleSequenceException (com.hazelcast.ringbuffer.StaleSequenceException)1 DistributedObjectDestroyedException (com.hazelcast.spi.exception.DistributedObjectDestroyedException)1 TopicOverloadException (com.hazelcast.topic.TopicOverloadException)1 ReliableTopicMessage (com.hazelcast.topic.impl.reliable.ReliableTopicMessage)1 ExecutionException (java.util.concurrent.ExecutionException)1