public interface MQProducer extends MQAdmin
| 限定符和类型 | 方法和说明 |
|---|---|
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()
启动服务
|
createTopic, earliestMsgStoreTime, maxOffset, minOffset, queryMessage, searchOffset, viewMessagevoid start()
throws MQClientException
void shutdown()
List<MessageQueue> fetchPublishMessageQueues(String topic) throws MQClientException
topic - 消息TopicMQClientExceptionSendResult send(Message msg) throws MQClientException, com.alibaba.rocketmq.remoting.exception.RemotingException, MQBrokerException, InterruptedException
msg - 消息InterruptedExceptionMQBrokerExceptioncom.alibaba.rocketmq.remoting.exception.RemotingExceptionMQClientExceptionvoid send(Message msg, SendCallback sendCallback) throws MQClientException, com.alibaba.rocketmq.remoting.exception.RemotingException, InterruptedException
msg - 消息sendCallback - 发送结果通过此接口回调MQClientExceptioncom.alibaba.rocketmq.remoting.exception.RemotingExceptionInterruptedExceptionvoid sendOneway(Message msg) throws MQClientException, com.alibaba.rocketmq.remoting.exception.RemotingException, InterruptedException
msg - 消息MQClientExceptioncom.alibaba.rocketmq.remoting.exception.RemotingExceptionInterruptedExceptionSendResult send(Message msg, MessageQueue mq) throws MQClientException, com.alibaba.rocketmq.remoting.exception.RemotingException, MQBrokerException, InterruptedException
msg - 消息mq - 队列InterruptedExceptionMQBrokerExceptioncom.alibaba.rocketmq.remoting.exception.RemotingExceptionMQClientExceptionvoid send(Message msg, MessageQueue mq, SendCallback sendCallback) throws MQClientException, com.alibaba.rocketmq.remoting.exception.RemotingException, InterruptedException
msg - 消息mq - 队列sendCallback - 发送结果通过此接口回调InterruptedExceptioncom.alibaba.rocketmq.remoting.exception.RemotingExceptionMQClientExceptionvoid sendOneway(Message msg, MessageQueue mq) throws MQClientException, com.alibaba.rocketmq.remoting.exception.RemotingException, InterruptedException
msg - 消息mq - 队列MQClientExceptioncom.alibaba.rocketmq.remoting.exception.RemotingExceptionInterruptedExceptionSendResult send(Message msg, MessageQueueSelector selector, Object arg) throws MQClientException, com.alibaba.rocketmq.remoting.exception.RemotingException, MQBrokerException, InterruptedException
msg - 消息selector - 队列选择器,发送时会回调arg - 回调队列选择器时,此参数会传入队列选择方法InterruptedExceptionMQBrokerExceptioncom.alibaba.rocketmq.remoting.exception.RemotingExceptionMQClientExceptionvoid send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback) throws MQClientException, com.alibaba.rocketmq.remoting.exception.RemotingException, InterruptedException
msg - 消息selector - 队列选择器,发送时会回调arg - 回调队列选择器时,此参数会传入队列选择方法sendCallback - 发送结果通过此接口回调MQClientExceptioncom.alibaba.rocketmq.remoting.exception.RemotingExceptionInterruptedExceptionvoid sendOneway(Message msg, MessageQueueSelector selector, Object arg) throws MQClientException, com.alibaba.rocketmq.remoting.exception.RemotingException, InterruptedException
msg - 消息selector - 队列选择器,发送时会回调arg - 回调队列选择器时,此参数会传入队列选择方法MQClientExceptioncom.alibaba.rocketmq.remoting.exception.RemotingExceptionInterruptedExceptionTransactionSendResult sendMessageInTransaction(Message msg, LocalTransactionExecuter tranExecuter, Object arg) throws MQClientException
Copyright © 2012–2013. All rights reserved.