當前位置: 首頁>>代碼示例>>Java>>正文


Java HazelcastInstance.getTopic方法代碼示例

本文整理匯總了Java中com.hazelcast.core.HazelcastInstance.getTopic方法的典型用法代碼示例。如果您正苦於以下問題:Java HazelcastInstance.getTopic方法的具體用法?Java HazelcastInstance.getTopic怎麽用?Java HazelcastInstance.getTopic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hazelcast.core.HazelcastInstance的用法示例。


在下文中一共展示了HazelcastInstance.getTopic方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: LocalRegionCache

import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
/**
 * @param name              the name for this region cache, which is also used to retrieve configuration/topic
 * @param hazelcastInstance the {@code HazelcastInstance} to which this region cache belongs, used to retrieve
 *                          configuration and to lookup an {@link ITopic} to register a {@link MessageListener}
 *                          with if {@code withTopic} is {@code true} (optional)
 * @param metadata          metadata describing the cached data, used to compare data versions (optional)
 * @param withTopic         {@code true} to register a {@link MessageListener} with the {@link ITopic} whose name
 *                          matches this region cache <i>if</i> a {@code HazelcastInstance} was provided to look
 *                          up the topic; otherwise, {@code false} not to register a listener even if an instance
 *                          was provided
 */
public LocalRegionCache(final String name, final HazelcastInstance hazelcastInstance,
                        final CacheDataDescription metadata, final boolean withTopic) {
    this.hazelcastInstance = hazelcastInstance;
    try {
        config = hazelcastInstance != null ? hazelcastInstance.getConfig().findMapConfig(name) : null;
    } catch (UnsupportedOperationException ignored) {
        EmptyStatement.ignore(ignored);
    }
    versionComparator = metadata != null && metadata.isVersioned() ? metadata.getVersionComparator() : null;
    cache = new ConcurrentHashMap<Object, Expirable>();
    markerIdCounter = new AtomicLong();

    messageListener = createMessageListener();
    if (withTopic && hazelcastInstance != null) {
        topic = hazelcastInstance.getTopic(name);
        topic.addMessageListener(messageListener);
    } else {
        topic = null;
    }
}
 
開發者ID:hazelcast,項目名稱:hazelcast-hibernate5,代碼行數:32,代碼來源:LocalRegionCache.java

示例2: LocalRegionCache

import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
/**
 * @param name              the name for this region cache, which is also used to retrieve configuration/topic
 * @param hazelcastInstance the {@code HazelcastInstance} to which this region cache belongs, used to retrieve
 *                          configuration and to lookup an {@link ITopic} to register a {@link MessageListener}
 *                          with if {@code withTopic} is {@code true} (optional)
 * @param metadata          metadata describing the cached data, used to compare data versions (optional)
 * @param withTopic         {@code true} to register a {@link MessageListener} with the {@link ITopic} whose name
 *                          matches this region cache <i>if</i> a {@code HazelcastInstance} was provided to look
 *                          up the topic; otherwise, {@code false} not to register a listener even if an instance
 *                          was provided
 * @since 3.3
 */
public LocalRegionCache(final String name, final HazelcastInstance hazelcastInstance,
                        final CacheDataDescription metadata, final boolean withTopic) {
    this.hazelcastInstance = hazelcastInstance;
    try {
        config = hazelcastInstance != null ? hazelcastInstance.getConfig().findMapConfig(name) : null;
    } catch (UnsupportedOperationException ignored) {
        EmptyStatement.ignore(ignored);
    }
    versionComparator = metadata != null && metadata.isVersioned() ? metadata.getVersionComparator() : null;
    cache = new ConcurrentHashMap<Object, Expirable>();
    markerIdCounter = new AtomicLong();

    messageListener = createMessageListener();
    if (withTopic && hazelcastInstance != null) {
        topic = hazelcastInstance.getTopic(name);
        topic.addMessageListener(messageListener);
    } else {
        topic = null;
    }
}
 
開發者ID:hazelcast,項目名稱:hazelcast-hibernate,代碼行數:33,代碼來源:LocalRegionCache.java

示例3: main

import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
public static void main(String[] args) {
        HazelcastInstance hz = Hazelcast.newHazelcastInstance();
        ITopic<String> topic = hz.getTopic("foo");
//        topic.addMessageListener(System.out::println);
        while(true){
            topic.publish("Hi from Anatole at " + new Date());
        }
    }
 
開發者ID:apache,項目名稱:incubator-tamaya-sandbox,代碼行數:9,代碼來源:Test.java

示例4: init

import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
@Override
public void init() {
    ApplicationContext applicationContext = CurrentApplicationContext.CURRENT.get();
    HazelcastInstance hazelcastInstance = HazelcastHelper.getHazelcastInstance(applicationContext);
    topic = hazelcastInstance.getTopic("cyclos.EhCacheEvictionReplication");
    topic.addMessageListener(this);
    status = Status.STATUS_ALIVE;
    LOG.info("EhCache replication has started using Hazelcast");
}
 
開發者ID:mateli,項目名稱:OpenCyclos,代碼行數:10,代碼來源:HazelcastCacheManagerPeerProvider.java

示例5: HazelcastTopicConsumer

import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
public HazelcastTopicConsumer(HazelcastInstance hazelcastInstance, Endpoint endpoint, Processor processor, String cacheName) {
    super(hazelcastInstance, endpoint, processor, cacheName);

    ITopic<Object> topic = hazelcastInstance.getTopic(cacheName);
    topic.addMessageListener(new CamelMessageListener(this, cacheName));
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:7,代碼來源:HazelcastTopicConsumer.java

示例6: HazelcastTopicProducer

import com.hazelcast.core.HazelcastInstance; //導入方法依賴的package包/類
public HazelcastTopicProducer(HazelcastInstance hazelcastInstance, HazelcastDefaultEndpoint endpoint, String topicName) {
    super(endpoint);
    this.topic = hazelcastInstance.getTopic(topicName);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:5,代碼來源:HazelcastTopicProducer.java


注:本文中的com.hazelcast.core.HazelcastInstance.getTopic方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。