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 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 testWildcardConfig.
@Test
public void testWildcardConfig() {
Config config = new Config();
config.addRingBufferConfig(new RingbufferConfig("foo*").setCapacity(10));
config.addReliableTopicConfig(new ReliableTopicConfig("foo*").setTopicOverloadPolicy(DISCARD_NEWEST));
HazelcastInstance hz = createHazelcastInstance(config);
RingbufferService ringbufferService = getNodeEngineImpl(hz).getService(RingbufferService.SERVICE_NAME);
ReliableTopicProxy<String> topic = (ReliableTopicProxy<String>) hz.<String>getReliableTopic("foo");
Ringbuffer ringbuffer = topic.ringbuffer;
topic.publish("foo");
ReliableTopicProxy proxy = assertInstanceOf(ReliableTopicProxy.class, topic);
assertEquals(proxy.overloadPolicy, TopicOverloadPolicy.DISCARD_NEWEST);
final ConcurrentMap<Integer, Map<ObjectNamespace, RingbufferContainer>> containers = ringbufferService.getContainers();
assertEquals(1, containers.size());
final Map<ObjectNamespace, RingbufferContainer> partitionContainers = containers.get(ringbufferService.getRingbufferPartitionId(ringbuffer.getName()));
final ObjectNamespace ns = RingbufferService.getRingbufferNamespace(ringbuffer.getName());
assertTrue(partitionContainers.containsKey(ns));
assertEquals(0, ringbuffer.headSequence());
assertEquals(0, ringbuffer.tailSequence());
assertEquals(10, ringbuffer.capacity());
}
use of com.hazelcast.config.ReliableTopicConfig in project hazelcast by hazelcast.
the class ReliableTopicBlockTest method setup.
@Before
public void setup() {
Config config = smallInstanceConfig();
config.addRingBufferConfig(new RingbufferConfig("blockingReliableTopic*").setCapacity(10).setTimeToLiveSeconds(60));
config.addReliableTopicConfig(new ReliableTopicConfig("blockingReliableTopic*").setReadBatchSize(10).setTopicOverloadPolicy(TopicOverloadPolicy.BLOCK));
HazelcastInstance[] instances = createHazelcastInstanceFactory(1).newInstances(config);
local = instances[0];
HazelcastInstance target = instances[instances.length - 1];
String name = randomNameOwnedBy(target, "reliableTopic");
topic = local.getReliableTopic(name);
}
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);
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