@Override public void onEvent() { if (receiveLink != null && receiveLink.getLocalState() != EndpointState.CLOSED) { receiveLink.close(); } else if (receiveLink == null || receiveLink.getRemoteState() == EndpointState.CLOSED) { if (closeTimer != null && !closeTimer.isCancelled()) { closeTimer.cancel(false); } linkClose.complete(null); } } });
@Override public void onEvent() { receiveWork.onEvent(); if (!MessageReceiver.this.getIsClosingOrClosed() && (receiveLink.getLocalState() == EndpointState.CLOSED || receiveLink.getRemoteState() == EndpointState.CLOSED)) { createReceiveLink(); } } }
@Override public void onEvent() { if (InternalReceiver.this.receiveLink != null && InternalReceiver.this.receiveLink.getLocalState() != EndpointState.CLOSED) { TRACE_LOGGER.debug("Closing internal receive link of requestresponselink to {}", RequestResponseLink.this.linkPath); InternalReceiver.this.receiveLink.close(); InternalReceiver.this.parent.underlyingFactory.deregisterForConnectionError(InternalReceiver.this.receiveLink); if(waitForCloseCompletion) { RequestResponseLink.scheduleLinkCloseTimeout(InternalReceiver.this.closeFuture, InternalReceiver.this.parent.underlyingFactory.getOperationTimeout(), InternalReceiver.this.receiveLink.getName()); } else { AsyncUtil.completeFuture(InternalReceiver.this.closeFuture, null); } } } });
@Override public void onEvent() { if (!MessageReceiver.this.getIsClosingOrClosed() && (receiveLink.getLocalState() == EndpointState.CLOSED || receiveLink.getRemoteState() == EndpointState.CLOSED)) { createReceiveLink(); underlyingFactory.getRetryPolicy().incrementRetryCount(getClientId()); } } });
@Override public void onEvent() { if (!MessageReceiver.this.getIsClosingOrClosed() && (receiveLink == null || receiveLink.getLocalState() == EndpointState.CLOSED || receiveLink.getRemoteState() == EndpointState.CLOSED)) { createReceiveLink(); underlyingFactory.getRetryPolicy().incrementRetryCount(getClientId()); } } });
private synchronized CompletableFuture<Void> ensureLinkIsOpen() if (!(this.receiveLink.getLocalState() == EndpointState.ACTIVE && this.receiveLink.getRemoteState() == EndpointState.ACTIVE))
public CompletableFuture<Message> requestAysnc(Message requestMessage, TransactionContext transaction, Duration timeout) { this.throwIfClosed(null); CompletableFuture<Message> responseFuture = new CompletableFuture<Message>(); RequestResponseWorkItem workItem = new RequestResponseWorkItem(requestMessage, transaction, responseFuture, timeout); String requestId = "request:" + this.requestCounter.incrementAndGet(); requestMessage.setMessageId(requestId); requestMessage.setReplyTo(this.replyTo); this.pendingRequests.put(requestId, workItem); workItem.setTimeoutTask(this.scheduleRequestTimeout(requestId, timeout)); TRACE_LOGGER.debug("Sending request with id:{}", requestId); this.amqpSender.sendRequest(requestId, false); // Check and recreate links if necessary if(!((this.amqpSender.sendLink.getLocalState() == EndpointState.ACTIVE && this.amqpSender.sendLink.getRemoteState() == EndpointState.ACTIVE) && (this.amqpReceiver.receiveLink.getLocalState() == EndpointState.ACTIVE && this.amqpReceiver.receiveLink.getRemoteState() == EndpointState.ACTIVE))) { this.ensureUniqueLinkRecreation(); } return responseFuture; }
if (this.receiveLink != null && this.receiveLink.getLocalState() != EndpointState.CLOSED)
if (this.receiveLink != null && this.receiveLink.getLocalState() != EndpointState.CLOSED)
@Override public IOObjectState getState() { if (sendLink.getLocalState() == EndpointState.UNINITIALIZED || receiveLink.getLocalState() == EndpointState.UNINITIALIZED || sendLink.getRemoteState() == EndpointState.UNINITIALIZED || receiveLink.getRemoteState() == EndpointState.UNINITIALIZED) return IOObjectState.OPENING; if (sendLink.getRemoteState() == EndpointState.ACTIVE && receiveLink.getRemoteState() == EndpointState.ACTIVE && sendLink.getLocalState() == EndpointState.ACTIVE && receiveLink.getRemoteState() == EndpointState.ACTIVE) return IOObjectState.OPENED; if (sendLink.getRemoteState() == EndpointState.CLOSED && receiveLink.getRemoteState() == EndpointState.CLOSED) return IOObjectState.CLOSED; return IOObjectState.CLOSING; // only left cases are if some are active and some are closed }