|
||||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |
java.lang.Object com.taobao.metamorphosis.client.producer.SimpleMessageProducer
public class SimpleMessageProducer
消费生产者实现
字段摘要 | |
---|---|
protected static long |
DEFAULT_OP_TIMEOUT
|
protected ThreadLocal<com.taobao.metamorphosis.client.producer.SimpleMessageProducer.LastSentInfo> |
lastSentInfo
事务相关代码 |
protected PartitionSelector |
partitionSelector
|
protected ProducerZooKeeper |
producerZooKeeper
|
protected RemotingClientWrapper |
remotingClient
|
protected String |
sessionId
|
protected ThreadLocal<TransactionContext> |
transactionContext
与线程关联的事务上下文 |
protected long |
transactionRequestTimeoutInMills
|
protected int |
transactionTimeout
|
构造方法摘要 | |
---|---|
SimpleMessageProducer(MetaMessageSessionFactory messageSessionFactory,
RemotingClientWrapper remotingClient,
PartitionSelector partitionSelector,
ProducerZooKeeper producerZooKeeper,
String sessionId)
|
方法摘要 | |
---|---|
protected void |
beforeSendMessageFirstTime(String serverUrl)
在第一次发送前开始事务 |
void |
beginTransaction()
开启一个事务并关联到当前线程 |
protected void |
checkMessage(Message message)
|
protected void |
checkState()
|
void |
commit()
提交事务,将事务内发送的消息持久化,此方法仅能在beginTransaction之后调用 |
MetaMessageSessionFactory |
getParent()
|
PartitionSelector |
getPartitionSelector()
返回本生产者的分区选择器 |
String |
getSessionId()
|
protected TransactionId |
getTransactionId()
返回事务id |
int |
getTransactionTimeout()
返回当前设置的事务超时时间,默认为0,表示永不超时 |
protected BooleanCommand |
invokeToGroup(String serverUrl,
Partition partition,
PutCommand putCommand,
Message message,
long timeout,
TimeUnit unit)
|
protected boolean |
isInTransaction()
判断是否处于事务中 |
boolean |
isOrdered()
已过时。 |
protected void |
logLastSentInfo(String serverUrl)
记录上一次投递信息 |
void |
publish(String topic)
发布topic,以便producer从zookeeper获取broker列表并连接,在发送消息前必须先调用此方法 |
void |
removeContext(TransactionContext ctx)
|
protected void |
resetLastSentInfo()
|
void |
rollback()
回滚事务内所发送的任何消息,此方法仅能在beginTransaction之后调用 |
SendResult |
sendMessage(Message message)
发送消息 |
SendResult |
sendMessage(Message message,
long timeout,
TimeUnit unit)
发送消息,如果超出指定的时间内没有返回,则抛出异常 |
void |
sendMessage(Message message,
SendMessageCallback cb)
异步发送消息,在默认时间内(3秒)回调callback,此模式下无法使用事务 |
void |
sendMessage(Message message,
SendMessageCallback cb,
long time,
TimeUnit unit)
异步发送消息,在指定时间内回调callback,此模式下无法使用事务 |
protected SendResult |
sendMessageToServer(Message message,
long timeout,
TimeUnit unit)
正常的消息发送到服务器 |
void |
setDefaultTopic(String topic)
设置发送消息的默认topic,当发送的message的topic没有找到可用broker和分区的时候,选择这个默认topic指定的broker发送 。 |
void |
setTransactionRequestTimeout(long time,
TimeUnit timeUnit)
Set transaction command request timeout.default is five seconds. |
void |
setTransactionTimeout(int seconds)
设置事务超时时间,从事务开始计时,如果超过设定时间还没有提交或者回滚,则服务端将无条件回滚该事务。 |
void |
shutdown()
关闭生产者,释放资源 |
从类 java.lang.Object 继承的方法 |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
字段详细信息 |
---|
protected static final long DEFAULT_OP_TIMEOUT
protected final RemotingClientWrapper remotingClient
protected final PartitionSelector partitionSelector
protected final ProducerZooKeeper producerZooKeeper
protected final String sessionId
protected volatile int transactionTimeout
protected long transactionRequestTimeoutInMills
protected final ThreadLocal<com.taobao.metamorphosis.client.producer.SimpleMessageProducer.LastSentInfo> lastSentInfo
protected final ThreadLocal<TransactionContext> transactionContext
构造方法详细信息 |
---|
public SimpleMessageProducer(MetaMessageSessionFactory messageSessionFactory, RemotingClientWrapper remotingClient, PartitionSelector partitionSelector, ProducerZooKeeper producerZooKeeper, String sessionId)
方法详细信息 |
---|
public void setTransactionRequestTimeout(long time, TimeUnit timeUnit)
MessageProducer
复制的描述
MessageProducer
中的 setTransactionRequestTimeout
public MetaMessageSessionFactory getParent()
public PartitionSelector getPartitionSelector()
MessageProducer
复制的描述
MessageProducer
中的 getPartitionSelector
@Deprecated public boolean isOrdered()
MessageProducer
复制的描述
MessageProducer
中的 isOrdered
public void publish(String topic)
MessageProducer
复制的描述
MessageProducer
中的 publish
public void setDefaultTopic(String topic)
MessageProducer
复制的描述
MessageProducer
中的 setDefaultTopic
public SendResult sendMessage(Message message, long timeout, TimeUnit unit) throws MetaClientException, InterruptedException
MessageProducer
复制的描述
MessageProducer
中的 sendMessage
message
- 消息对象timeout
- 超时时间unit
- 超时的时间单位
MetaClientException
- 客户端异常
InterruptedException
- 响应中断protected SendResult sendMessageToServer(Message message, long timeout, TimeUnit unit) throws MetaClientException, InterruptedException, MetaOpeartionTimeoutException
MetaClientException
InterruptedException
MetaOpeartionTimeoutException
public void removeContext(TransactionContext ctx)
TransactionSession
中的 removeContext
public String getSessionId()
TransactionSession
中的 getSessionId
public void setTransactionTimeout(int seconds) throws MetaClientException
MessageProducer
复制的描述
MessageProducer
中的 setTransactionTimeout
seconds
- 事务超时时间,单位:秒
MetaClientException
MessageProducer.beginTransaction()
,
MessageProducer.rollback()
,
MessageProducer.commit()
public int getTransactionTimeout() throws MetaClientException
MessageProducer
复制的描述
MessageProducer
中的 getTransactionTimeout
MetaClientException
public void beginTransaction() throws MetaClientException
MessageProducer
中的 beginTransaction
MetaClientException
- 如果已经处于事务中,则抛出TransactionInProgressException异常protected void beforeSendMessageFirstTime(String serverUrl) throws MetaClientException, XAException
serverUrl
-
MetaClientException
XAException
protected void logLastSentInfo(String serverUrl)
serverUrl
- protected TransactionId getTransactionId() throws MetaClientException
MetaClientException
protected boolean isInTransaction()
public void commit() throws MetaClientException
MessageProducer
中的 commit
MetaClientException
beginTransaction()
public void rollback() throws MetaClientException
MessageProducer
中的 rollback
MetaClientException
beginTransaction()
protected void resetLastSentInfo()
protected BooleanCommand invokeToGroup(String serverUrl, Partition partition, PutCommand putCommand, Message message, long timeout, TimeUnit unit) throws InterruptedException, TimeoutException, com.taobao.gecko.service.exception.NotifyRemotingException
InterruptedException
TimeoutException
com.taobao.gecko.service.exception.NotifyRemotingException
protected void checkState()
protected void checkMessage(Message message) throws MetaClientException
MetaClientException
public void sendMessage(Message message, SendMessageCallback cb, long time, TimeUnit unit)
MessageProducer
复制的描述
MessageProducer
中的 sendMessage
public void sendMessage(Message message, SendMessageCallback cb)
MessageProducer
复制的描述
MessageProducer
中的 sendMessage
public SendResult sendMessage(Message message) throws MetaClientException, InterruptedException
MessageProducer
复制的描述
MessageProducer
中的 sendMessage
message
- 消息对象
MetaClientException
- 客户端异常
InterruptedException
- 响应中断public void shutdown() throws MetaClientException
MessageProducer
复制的描述
MessageProducer
中的 shutdown
Shutdownable
中的 shutdown
MetaClientException
|
||||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |