use of org.apache.activemq.transport.InactivityIOException in project activemq-artemis by apache.
the class AmqpConnection method doOpenCompletion.
// ----- Internal implementation ------------------------------------------//
@Override
protected void doOpenCompletion() {
// If the remote indicates that a close is pending, don't open.
if (getEndpoint().getRemoteProperties() == null || !getEndpoint().getRemoteProperties().containsKey(CONNECTION_OPEN_FAILED)) {
if (!isIdleProcessingDisabled()) {
// Using nano time since it is not related to the wall clock, which may change
long initialNow = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
long initialKeepAliveDeadline = protonTransport.tick(initialNow);
if (initialKeepAliveDeadline != 0) {
getScheduler().schedule(new Runnable() {
@Override
public void run() {
try {
if (getEndpoint().getLocalState() != EndpointState.CLOSED) {
LOG.debug("Client performing next idle check");
// Using nano time since it is not related to the wall clock, which may change
long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
long deadline = protonTransport.tick(now);
pumpToProtonTransport();
if (protonTransport.isClosed()) {
LOG.debug("Transport closed after inactivity check.");
throw new InactivityIOException("Channel was inactive for too long");
} else {
if (deadline != 0) {
getScheduler().schedule(this, deadline - now, TimeUnit.MILLISECONDS);
}
}
}
} catch (Exception e) {
try {
transport.close();
} catch (IOException e1) {
}
fireClientException(e);
}
}
}, initialKeepAliveDeadline - initialNow, TimeUnit.MILLISECONDS);
}
}
super.doOpenCompletion();
}
}
Aggregations