public class RemotingClient extends MessageAdaptor implements Closeable
| Modifier and Type | Field and Description |
|---|---|
protected String |
brokerAddress |
| Constructor and Description |
|---|
RemotingClient(String address,
Dispatcher dispatcher) |
RemotingClient(String host,
int port,
Dispatcher dispatcher) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
attr(String key) |
<T> void |
attr(String key,
T value) |
void |
close() |
void |
connect(int timeoutMillis) |
void |
connectIfNeed() |
protected void |
doConnect() |
void |
ensureConnected() |
String |
getBrokerAddress() |
int |
getConnectTimeout() |
int |
getHeartbeatInterval() |
int |
getReadTimeout() |
Session |
getSession() |
boolean |
hasConnected() |
void |
invokeAsync(Message req,
ResultCallback callback) |
Message |
invokeSync(Message req) |
Message |
invokeSync(Message req,
int timeout)
返回null标识超时
|
void |
onException(Throwable e,
Session sess)
Session各类错误发生时回调
|
void |
onMessage(Object obj,
Session sess)
Session接受到消息对象
|
void |
onSessionConnected(Session sess)
客户端链接成功后回调
|
void |
send(Message msg)
asynchronous send message, return message fall into client's callback
异步发送消息,消息没有Ticket匹配,由Client的消息回调处理
|
void |
setConnectedCallback(ConnectedCallback connectedCallback) |
void |
setConnectTimeout(int connectTimeout) |
void |
setErrorCallback(ErrorCallback errorCallback) |
void |
setHeartbeatInterval(int heartbeatInterval) |
void |
setMessageCallback(MessageCallback messageCallback) |
void |
setReadTimeout(int readTimeout) |
decode, encodeonSessionAccepted, onSessionDestroyed, onSessionRegisteredprotected final String brokerAddress
public RemotingClient(String address, Dispatcher dispatcher)
public RemotingClient(String host, int port, Dispatcher dispatcher)
protected void doConnect()
throws IOException
IOExceptionpublic void connect(int timeoutMillis)
throws IOException
IOExceptionpublic boolean hasConnected()
public void ensureConnected()
public void connectIfNeed()
throws IOException
IOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic void invokeAsync(Message req, ResultCallback callback) throws IOException
IOExceptionpublic Message invokeSync(Message req) throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic Message invokeSync(Message req, int timeout) throws IOException, InterruptedException
req - timeout - IOExceptionInterruptedExceptionpublic void send(Message msg) throws IOException
msg - IOExceptionpublic int getReadTimeout()
public void setReadTimeout(int readTimeout)
public int getConnectTimeout()
public void setConnectTimeout(int connectTimeout)
public Session getSession()
public String getBrokerAddress()
public <T> T attr(String key)
public <T> void attr(String key, T value)
public void onMessage(Object obj, Session sess) throws IOException
IoAdaptoronMessage in class IoAdaptorIOExceptionpublic void onException(Throwable e, Session sess) throws IOException
IoAdaptoronException in class IoAdaptorIOExceptionpublic void onSessionConnected(Session sess) throws IOException
IoAdaptoronSessionConnected in class IoAdaptorIOExceptionpublic void setMessageCallback(MessageCallback messageCallback)
public void setErrorCallback(ErrorCallback errorCallback)
public void setConnectedCallback(ConnectedCallback connectedCallback)
public int getHeartbeatInterval()
public void setHeartbeatInterval(int heartbeatInterval)
Copyright © 2015. All rights reserved.