use of com.hazelcast.config.ReliableTopicConfig in project hazelcast by hazelcast.
the class TopicOverloadTest method setupCluster.
@Before
public void setupCluster() {
Config config = new Config();
config.addRingBufferConfig(new RingbufferConfig("when*").setCapacity(100).setTimeToLiveSeconds(30));
config.addReliableTopicConfig(new ReliableTopicConfig("whenError_*").setTopicOverloadPolicy(TopicOverloadPolicy.ERROR));
config.addReliableTopicConfig(new ReliableTopicConfig("whenDiscardOldest_*").setTopicOverloadPolicy(TopicOverloadPolicy.DISCARD_OLDEST));
config.addReliableTopicConfig(new ReliableTopicConfig("whenDiscardNewest_*").setTopicOverloadPolicy(TopicOverloadPolicy.DISCARD_NEWEST));
config.addReliableTopicConfig(new ReliableTopicConfig("whenBlock_*").setTopicOverloadPolicy(TopicOverloadPolicy.BLOCK));
HazelcastInstance hz = createHazelcastInstance(config);
serializationService = getSerializationService(hz);
String topicName = getTestMethodName();
topic = hz.<String>getReliableTopic(topicName);
ringbuffer = ((ReliableTopicProxy<String>) topic).ringbuffer;
}
use of com.hazelcast.config.ReliableTopicConfig in project hazelcast by hazelcast.
the class ReliableTopicCreateTest method testConfiguredListenerClassAndHazelcastInstanceAware.
@Test
public void testConfiguredListenerClassAndHazelcastInstanceAware() {
Config config = new Config();
config.addReliableTopicConfig(new ReliableTopicConfig("foo*").addMessageListenerConfig(new ListenerConfig(InstanceAwareReliableMessageListenerMock.class.getName())));
HazelcastInstance hz = createHazelcastInstance(config);
ITopic topic = hz.getReliableTopic("foo");
ReliableTopicProxy proxy = assertInstanceOf(ReliableTopicProxy.class, topic);
// check there is one listener.
assertEquals(1, proxy.runnersMap.size());
// check that the listener is of the right class.
ReliableMessageListenerRunner runner = (ReliableMessageListenerRunner) proxy.runnersMap.values().iterator().next();
InstanceAwareReliableMessageListenerMock mock = assertInstanceOf(InstanceAwareReliableMessageListenerMock.class, runner.listener);
assertNotNull(mock.hz);
}
use of com.hazelcast.config.ReliableTopicConfig in project hazelcast by hazelcast.
the class ReliableTopicCreateTest method testConfiguredListenerClassNotExist.
@Test(expected = HazelcastException.class)
public void testConfiguredListenerClassNotExist() {
Config config = new Config();
config.addReliableTopicConfig(new ReliableTopicConfig("foo*").addMessageListenerConfig(new ListenerConfig("kfosajdajdksajdj")));
HazelcastInstance hz = createHazelcastInstance(config);
hz.getReliableTopic("foo");
fail();
}
use of com.hazelcast.config.ReliableTopicConfig in project hazelcast by hazelcast.
the class ReliableTopicCreateTest method testConfiguredListenerInstance.
@Test
public void testConfiguredListenerInstance() {
final ReliableMessageListenerMock messageListener = new ReliableMessageListenerMock();
Config config = new Config();
config.addReliableTopicConfig(new ReliableTopicConfig("foo*").addMessageListenerConfig(new ListenerConfig(messageListener)));
HazelcastInstance hz = createHazelcastInstance(config);
ITopic<String> topic = hz.getReliableTopic("foo");
ReliableTopicProxy proxy = assertInstanceOf(ReliableTopicProxy.class, topic);
assertEquals(1, proxy.runnersMap.size());
topic.publish("item");
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertContains(messageListener.objects, "item");
}
});
}
use of com.hazelcast.config.ReliableTopicConfig in project hazelcast by hazelcast.
the class ReliableTopicAbstractTest method setup.
@Before
public void setup() {
ReliableTopicConfig topicConfig = new ReliableTopicConfig("reliableTopic*");
RingbufferConfig ringbufferConfig = new RingbufferConfig(topicConfig.getName());
ringbufferConfig.setCapacity(CAPACITY);
Config config = new Config();
config.addReliableTopicConfig(topicConfig);
config.addRingBufferConfig(ringbufferConfig);
HazelcastInstance[] instances = newInstances(config);
local = instances[0];
HazelcastInstance target = instances[instances.length - 1];
String name = randomNameOwnedBy(target, "reliableTopic");
topic = (ReliableTopicProxy<String>) local.<String>getReliableTopic(name);
}
Aggregations