com.taobao.metamorphosis.client
接口 MessageSessionFactory

所有超级接口:
Shutdownable
所有已知子接口:
AsyncMessageSessionFactory, BroadcastMessageSessionFactory, ExtMessageSessionFactory, OrderedMessageSessionFactory, XAMessageSessionFactory
所有已知实现类:
AsyncMetaMessageSessionFactory, ExtMetaMessageSessionFactory, MetaBroadcastMessageSessionFactory, MetaMessageSessionFactory, OrderedMetaMessageSessionFactory, SlaveMetaMessageSessionFactory, XAMetaMessageSessionFactory

public interface MessageSessionFactory
extends Shutdownable

消息会话工厂,meta客户端的主接口,推荐一个应用只使用一个MessageSessionFactory

作者:
boyan

方法摘要
 MessageConsumer createConsumer(ConsumerConfig consumerConfig)
          创建消息消费者,默认将offset存储在zk
 MessageConsumer createConsumer(ConsumerConfig consumerConfig, OffsetStorage offsetStorage)
          创建消息消费者,使用指定的offset存储器
 MessageProducer createProducer()
          创建消息生产者,默认使用轮询分区选择器
 MessageProducer createProducer(boolean ordered)
          已过时。 
 MessageProducer createProducer(PartitionSelector partitionSelector)
          创建消息生产者
 MessageProducer createProducer(PartitionSelector partitionSelector, boolean ordered)
          已过时。 
 TopicBrowser createTopicBrowser(String topic)
          Returns a topic browser to iterate all messages under the topic from all alive brokers.
 TopicBrowser createTopicBrowser(String topic, int maxSize, long timeout, TimeUnit timeUnit)
          Returns a topic browser to iterate all messages under the topic from all alive brokers.
 List<Partition> getPartitionsForTopic(String topic)
          Get partitions list for topic
 Map<InetSocketAddress,StatsResult> getStats()
          Get statistics information from all brokers in this session factory.
 StatsResult getStats(InetSocketAddress target)
          Get statistics information from special broker.If the broker is not connected in this session factory,it will return null.
 StatsResult getStats(InetSocketAddress target, String item)
          Get item statistics information from special broker.If the broker is not connected in this session factory,it will return null.
 Map<InetSocketAddress,StatsResult> getStats(String item)
          Get item statistics information from all brokers in this session factory.
 void shutdown()
          关闭工厂
 

方法详细信息

shutdown

void shutdown()
              throws MetaClientException
关闭工厂

指定者:
接口 Shutdownable 中的 shutdown
抛出:
MetaClientException

createProducer

MessageProducer createProducer(PartitionSelector partitionSelector)
创建消息生产者

参数:
partitionSelector - 分区选择器
返回:

createProducer

MessageProducer createProducer()
创建消息生产者,默认使用轮询分区选择器

返回:

createProducer

@Deprecated
MessageProducer createProducer(boolean ordered)
已过时。 

创建消息生产者,默认使用轮询分区选择器。本方法已经废弃,请勿使用,不排除在未来某个版本删除。

参数:
ordered - 是否有序,true为有序,如果有序,则消息按照发送顺序保存在MQ server
返回:

createProducer

@Deprecated
MessageProducer createProducer(PartitionSelector partitionSelector,
                                          boolean ordered)
已过时。 

创建消息生产者,本方法已经废弃,请勿使用,不排除在未来某个版本删除。

参数:
partitionSelector - 分区选择器
ordered - 是否有序,true为有序,如果有序,则消息按照发送顺序保存在MQ server
返回:

createConsumer

MessageConsumer createConsumer(ConsumerConfig consumerConfig)
创建消息消费者,默认将offset存储在zk

参数:
consumerConfig - 消费者配置
返回:

getStats

Map<InetSocketAddress,StatsResult> getStats()
                                            throws InterruptedException
Get statistics information from all brokers in this session factory.

返回:
statistics result
抛出:
InterruptedException
从以下版本开始:
1.4.2

getStats

Map<InetSocketAddress,StatsResult> getStats(String item)
                                            throws InterruptedException
Get item statistics information from all brokers in this session factory.

参数:
item - stats item,could be "topics","realtime","offsets" or a special topic
返回:
statistics result
抛出:
InterruptedException
从以下版本开始:
1.4.2

getStats

StatsResult getStats(InetSocketAddress target)
                     throws InterruptedException
Get statistics information from special broker.If the broker is not connected in this session factory,it will return null.

参数:
target - stats broker
返回:
statistics result
抛出:
InterruptedException
从以下版本开始:
1.4.2

getStats

StatsResult getStats(InetSocketAddress target,
                     String item)
                     throws InterruptedException
Get item statistics information from special broker.If the broker is not connected in this session factory,it will return null.

参数:
target - stats broker
item - stats item,could be "topics","realtime","offsets" or a special topic
返回:
statistics result
抛出:
InterruptedException
从以下版本开始:
1.4.2

createConsumer

MessageConsumer createConsumer(ConsumerConfig consumerConfig,
                               OffsetStorage offsetStorage)
创建消息消费者,使用指定的offset存储器

参数:
consumerConfig - 消费者配置
offsetStorage - offset存储器
返回:

getPartitionsForTopic

List<Partition> getPartitionsForTopic(String topic)
Get partitions list for topic

参数:
topic -
返回:
partitions list

createTopicBrowser

TopicBrowser createTopicBrowser(String topic,
                                int maxSize,
                                long timeout,
                                TimeUnit timeUnit)
Returns a topic browser to iterate all messages under the topic from all alive brokers.

参数:
topic - the topic
maxSize - fetch batch size in bytes.
timeout - timeout value to fetch messages.
timeUnit - timeout value unit.
返回:
topic browser
从以下版本开始:
1.4.5

createTopicBrowser

TopicBrowser createTopicBrowser(String topic)
Returns a topic browser to iterate all messages under the topic from all alive brokers.

参数:
topic - the topic
返回:
topic browser
从以下版本开始:
1.4.5
另请参见:
createTopicBrowser(String, int, long, TimeUnit)


Copyright © 2010–2013. All rights reserved.