com.alibaba.rocketmq.client.producer
接口 MQProducer

所有超级接口:
MQAdmin
所有已知实现类:
DefaultMQProducer, TransactionMQProducer

public interface MQProducer
extends MQAdmin

消息生产者

从以下版本开始:
2013-7-25
作者:
shijia.wxr

方法摘要
 List<MessageQueue> fetchPublishMessageQueues(String topic)
          根据topic获取对应的MessageQueue,如果是顺序消息,则按照顺序消息配置返回
 SendResult send(Message msg)
          发送消息,同步调用
 SendResult send(Message msg, MessageQueue mq)
          向指定队列发送消息,同步调用
 SendResult send(Message msg, MessageQueueSelector selector, Object arg)
          发送消息,可以自定义选择队列,队列的总数可能会由于Broker的启停变化
如果要保证消息严格有序,在向运维人员申请Topic时,需要特别说明
同步调用
 void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback)
          发送消息,可以自定义选择队列,队列的总数可能会由于Broker的启停变化
如果要保证消息严格有序,在向运维人员申请Topic时,需要特别说明
异步调用
 void send(Message msg, MessageQueue mq, SendCallback sendCallback)
          向指定队列发送消息,异步调用
 void send(Message msg, SendCallback sendCallback)
          发送消息,异步调用
 TransactionSendResult sendMessageInTransaction(Message msg, LocalTransactionExecuter tranExecuter, Object arg)
           
 void sendOneway(Message msg)
          发送消息,Oneway形式,服务器不应答,无法保证消息是否成功到达服务器
 void sendOneway(Message msg, MessageQueue mq)
          向指定队列发送消息,Oneway形式,服务器不应答,无法保证消息是否成功到达服务器
 void sendOneway(Message msg, MessageQueueSelector selector, Object arg)
          发送消息,可以自定义选择队列,队列的总数可能会由于Broker的启停变化
如果要保证消息严格有序,在向运维人员申请Topic时,需要特别说明
Oneway形式,服务器不应答,无法保证消息是否成功到达服务器
 void shutdown()
          关闭服务,一旦关闭,此对象将不可用
 void start()
          启动服务
 
从接口 com.alibaba.rocketmq.client.MQAdmin 继承的方法
createTopic, earliestMsgStoreTime, maxOffset, minOffset, queryMessage, searchOffset, viewMessage
 

方法详细信息

start

void start()
           throws MQClientException
启动服务

抛出:
MQClientException

shutdown

void shutdown()
关闭服务,一旦关闭,此对象将不可用


fetchPublishMessageQueues

List<MessageQueue> fetchPublishMessageQueues(String topic)
                                             throws MQClientException
根据topic获取对应的MessageQueue,如果是顺序消息,则按照顺序消息配置返回

参数:
topic - 消息Topic
返回:
返回队列集合
抛出:
MQClientException

send

SendResult send(Message msg)
                throws MQClientException,
                       RemotingException,
                       MQBrokerException,
                       InterruptedException
发送消息,同步调用

参数:
msg - 消息
返回:
发送结果
抛出:
InterruptedException
MQBrokerException
RemotingException
MQClientException

send

void send(Message msg,
          SendCallback sendCallback)
          throws MQClientException,
                 RemotingException,
                 InterruptedException
发送消息,异步调用

参数:
msg - 消息
sendCallback - 发送结果通过此接口回调
抛出:
MQClientException
RemotingException
InterruptedException

sendOneway

void sendOneway(Message msg)
                throws MQClientException,
                       RemotingException,
                       InterruptedException
发送消息,Oneway形式,服务器不应答,无法保证消息是否成功到达服务器

参数:
msg - 消息
抛出:
MQClientException
RemotingException
InterruptedException

send

SendResult send(Message msg,
                MessageQueue mq)
                throws MQClientException,
                       RemotingException,
                       MQBrokerException,
                       InterruptedException
向指定队列发送消息,同步调用

参数:
msg - 消息
mq - 队列
返回:
发送结果
抛出:
InterruptedException
MQBrokerException
RemotingException
MQClientException

send

void send(Message msg,
          MessageQueue mq,
          SendCallback sendCallback)
          throws MQClientException,
                 RemotingException,
                 InterruptedException
向指定队列发送消息,异步调用

参数:
msg - 消息
mq - 队列
sendCallback - 发送结果通过此接口回调
抛出:
InterruptedException
RemotingException
MQClientException

sendOneway

void sendOneway(Message msg,
                MessageQueue mq)
                throws MQClientException,
                       RemotingException,
                       InterruptedException
向指定队列发送消息,Oneway形式,服务器不应答,无法保证消息是否成功到达服务器

参数:
msg - 消息
mq - 队列
抛出:
MQClientException
RemotingException
InterruptedException

send

SendResult send(Message msg,
                MessageQueueSelector selector,
                Object arg)
                throws MQClientException,
                       RemotingException,
                       MQBrokerException,
                       InterruptedException
发送消息,可以自定义选择队列,队列的总数可能会由于Broker的启停变化
如果要保证消息严格有序,在向运维人员申请Topic时,需要特别说明
同步调用

参数:
msg - 消息
selector - 队列选择器,发送时会回调
arg - 回调队列选择器时,此参数会传入队列选择方法
返回:
发送结果
抛出:
InterruptedException
MQBrokerException
RemotingException
MQClientException

send

void send(Message msg,
          MessageQueueSelector selector,
          Object arg,
          SendCallback sendCallback)
          throws MQClientException,
                 RemotingException,
                 InterruptedException
发送消息,可以自定义选择队列,队列的总数可能会由于Broker的启停变化
如果要保证消息严格有序,在向运维人员申请Topic时,需要特别说明
异步调用

参数:
msg - 消息
selector - 队列选择器,发送时会回调
arg - 回调队列选择器时,此参数会传入队列选择方法
sendCallback - 发送结果通过此接口回调
抛出:
MQClientException
RemotingException
InterruptedException

sendOneway

void sendOneway(Message msg,
                MessageQueueSelector selector,
                Object arg)
                throws MQClientException,
                       RemotingException,
                       InterruptedException
发送消息,可以自定义选择队列,队列的总数可能会由于Broker的启停变化
如果要保证消息严格有序,在向运维人员申请Topic时,需要特别说明
Oneway形式,服务器不应答,无法保证消息是否成功到达服务器

参数:
msg - 消息
selector - 队列选择器,发送时会回调
arg - 回调队列选择器时,此参数会传入队列选择方法
抛出:
MQClientException
RemotingException
InterruptedException

sendMessageInTransaction

TransactionSendResult sendMessageInTransaction(Message msg,
                                               LocalTransactionExecuter tranExecuter,
                                               Object arg)
                                               throws MQClientException
抛出:
MQClientException


Copyright © 2012-2014. All Rights Reserved.