public class AMQProtocolHandler extends Object implements ExceptionHandlingByteBufferReceiver, TransportActivity
Constructor and Description |
---|
AMQProtocolHandler(AMQConnection con)
Creates a new protocol handler, associated with the specified client connection instance.
|
Modifier and Type | Method and Description |
---|---|
void |
blockUntilNotFailingOver() |
void |
closeConnection(long timeout)
Closes the connection.
|
void |
closed()
Called when the network connection is closed.
|
void |
closeSession(AMQSession session) |
StateWaiter |
createWaiter(Set<AMQState> states) |
void |
exception(Throwable cause)
Invoked when any exception is thrown by the NetworkDriver
|
void |
failoverInProgress() |
String |
generateQueueName() |
AMQConnection |
getConnection() |
long |
getDefaultTimeout() |
CountDownLatch |
getFailoverLatch() |
long |
getLastReadTime() |
long |
getLastWriteTime() |
SocketAddress |
getLocalAddress() |
MethodRegistry |
getMethodRegistry() |
NetworkConnection |
getNetworkConnection() |
AMQProtocolSession |
getProtocolSession() |
ProtocolVersion |
getProtocolVersion() |
long |
getReadBytes() |
SocketAddress |
getRemoteAddress() |
protected ByteBufferSender |
getSender() |
AMQStateManager |
getStateManager() |
ProtocolVersion |
getSuggestedProtocolVersion() |
long |
getWrittenBytes() |
void |
heartbeatBodyReceived() |
void |
init(ConnectionSettings settings) |
void |
methodBodyReceived(int channelId,
AMQBody bodyFrame) |
void |
notifyFailoverStarting() |
void |
propagateExceptionToAllWaiters(Exception e)
There are two cases where we have other threads potentially blocking for events to be handled by this class.
|
void |
propagateExceptionToFrameListeners(Exception e)
This caters for the case where we only need to propagate an exception to the the frame listeners to interupt any
protocol level waits.
|
void |
readerIdle() |
void |
received(ByteBuffer msg) |
void |
setFailoverLatch(CountDownLatch failoverLatch) |
void |
setFailoverState(FailoverState failoverState) |
void |
setHeartbeatListener(HeartbeatListener listener) |
void |
setMaxFrameSize(long frameMax) |
void |
setNetworkConnection(NetworkConnection network) |
void |
setNetworkConnection(NetworkConnection network,
ByteBufferSender sender) |
void |
setStateManager(AMQStateManager stateManager) |
AMQMethodEvent |
syncWrite(AMQFrame frame,
Class responseClass)
More convenient method to write a frame and wait for it's response.
|
AMQMethodEvent |
syncWrite(AMQFrame frame,
Class responseClass,
long timeout)
More convenient method to write a frame and wait for it's response.
|
AMQMethodEvent |
writeCommandFrameAndWaitForReply(AMQDataBlock frame,
BlockingMethodFrameListener listener)
Convenience method that writes a frame to the protocol session and waits for a particular response.
|
AMQMethodEvent |
writeCommandFrameAndWaitForReply(AMQDataBlock frame,
BlockingMethodFrameListener listener,
long timeout)
Convenience method that writes a frame to the protocol session and waits for a particular response.
|
void |
writeFrame(AMQDataBlock frame) |
void |
writeFrame(AMQDataBlock frame,
boolean flush) |
void |
writerIdle() |
public AMQProtocolHandler(AMQConnection con)
con
- The client connection that this is the event handler for.public void closed()
TODO Clarify: presumably exceptionCaught is called when the client is sending during a connection failure and not otherwise? The above comment doesn't make that clear.
closed
in interface ByteBufferReceiver
public void readerIdle()
readerIdle
in interface TransportActivity
public void writerIdle()
writerIdle
in interface TransportActivity
public void exception(Throwable cause)
exception
in interface ExceptionHandlingByteBufferReceiver
public void propagateExceptionToAllWaiters(Exception e)
e
- the exception to propagatepropagateExceptionToFrameListeners(java.lang.Exception)
public void propagateExceptionToFrameListeners(Exception e)
FailoverHandler
.
Once the FailoverHandler
has re-established the connection then the listeners will be able to re-attempt
their protocol request and so listen again for the correct frame.e
- the exception to propagatepublic void notifyFailoverStarting()
public void failoverInProgress()
public void received(ByteBuffer msg)
received
in interface ByteBufferReceiver
public void methodBodyReceived(int channelId, AMQBody bodyFrame) throws QpidException
QpidException
public StateWaiter createWaiter(Set<AMQState> states) throws QpidException
QpidException
public void writeFrame(AMQDataBlock frame)
public void writeFrame(AMQDataBlock frame, boolean flush)
public AMQMethodEvent writeCommandFrameAndWaitForReply(AMQDataBlock frame, BlockingMethodFrameListener listener) throws QpidException, FailoverException
frame
- listener
- the blocking listener. Note the calling thread will block.QpidException
FailoverException
public AMQMethodEvent writeCommandFrameAndWaitForReply(AMQDataBlock frame, BlockingMethodFrameListener listener, long timeout) throws QpidException, FailoverException
frame
- listener
- the blocking listener. Note the calling thread will block.QpidException
FailoverException
public AMQMethodEvent syncWrite(AMQFrame frame, Class responseClass) throws QpidException, FailoverException
QpidException
FailoverException
public AMQMethodEvent syncWrite(AMQFrame frame, Class responseClass, long timeout) throws QpidException, FailoverException
QpidException
FailoverException
public void closeSession(AMQSession session) throws QpidException
QpidException
public void closeConnection(long timeout) throws QpidException
If a failover exception occurs whilst closing the connection it is ignored, as the connection is closed anyway.
timeout
- The timeout to wait for an acknowledgment to the close request.QpidException
- If the close fails for any reason.public long getReadBytes()
public long getWrittenBytes()
public void blockUntilNotFailingOver() throws InterruptedException
InterruptedException
public String generateQueueName()
public CountDownLatch getFailoverLatch()
public void setFailoverLatch(CountDownLatch failoverLatch)
public AMQConnection getConnection()
public AMQStateManager getStateManager()
public void setStateManager(AMQStateManager stateManager)
public AMQProtocolSession getProtocolSession()
public void setFailoverState(FailoverState failoverState)
public MethodRegistry getMethodRegistry()
public ProtocolVersion getProtocolVersion()
public SocketAddress getRemoteAddress()
public SocketAddress getLocalAddress()
public void setNetworkConnection(NetworkConnection network)
public void setNetworkConnection(NetworkConnection network, ByteBufferSender sender)
public long getLastReadTime()
getLastReadTime
in interface TransportActivity
public long getLastWriteTime()
getLastWriteTime
in interface TransportActivity
protected ByteBufferSender getSender()
public NetworkConnection getNetworkConnection()
public ProtocolVersion getSuggestedProtocolVersion()
public void setHeartbeatListener(HeartbeatListener listener)
public void heartbeatBodyReceived()
public void setMaxFrameSize(long frameMax)
public void init(ConnectionSettings settings)
public long getDefaultTimeout()
Copyright © 2006–2016 The Apache Software Foundation. All rights reserved.