@Test public void testHazelcastInstances() { assertNotNull(map1); assertNotNull(map2); assertNotNull(multiMap); assertNotNull(replicatedMap); assertNotNull(queue); assertNotNull(topic); assertNotNull(set); assertNotNull(list); assertNotNull(executorService); assertNotNull(idGenerator); assertNotNull(atomicLong); assertNotNull(atomicReference); assertNotNull(countDownLatch); assertNotNull(semaphore); assertNotNull(lock); assertEquals("map1", map1.getName()); assertEquals("map2", map2.getName()); assertEquals("testMultimap", multiMap.getName()); assertEquals("replicatedMap", replicatedMap.getName()); assertEquals("testQ", queue.getName()); assertEquals("testTopic", topic.getName()); assertEquals("set", set.getName()); assertEquals("list", list.getName()); assertEquals("idGenerator", idGenerator.getName()); assertEquals("atomicLong", atomicLong.getName()); assertEquals("atomicReference", atomicReference.getName()); assertEquals("countDownLatch", countDownLatch.getName()); assertEquals("semaphore", semaphore.getName()); }
@Test public void testName() { String randomTopicName = randomString(); HazelcastInstance hClient = createHazelcastInstance(); ITopic<?> topic = hClient.getTopic(randomTopicName); assertEquals(randomTopicName, topic.getName()); }
protected TopicMBean(ITopic managedObject, ManagementService service) { super(managedObject, service); objectName = service.createObjectName("ITopic", managedObject.getName()); MessageListener messageListener = new MessageListener() { public void onMessage(Message message) { totalMessageCount.incrementAndGet(); } }; registrationId = managedObject.addMessageListener(messageListener); }
/* * (non-Javadoc) * * @see * com.hazelcast.core.MessageListener#onMessage(com.hazelcast.core.Message) */ @Override public void onMessage(Message<byte[]> hzMsg) { // We always queue the message even if we have a message listener. We'll // immediately pull it out of the queue and dispatch in a separate thread. // This is important to prevent slow message handlers from blocking topic // distribution in Hazelcast. if (!queue.offer(hzMsg.getMessageObject())) { log.warn( format( "In-memory message buffer full for topic [%s]. " + "Messages will be lost. Consider increaing the speed of " + "the consumer or the message buffer.", msgTopic.getName())); return; } if (messageListener != null) { hazelcastMQContext.onConsumerDispatchReady(id); } }