@Override public void onFlow(final int creditIssued) { this.lastKnownLinkError = null; if (creditIssued <= 0) return; TRACE_LOGGER.debug("Received flow frame. path:{}, linkName:{}, remoteLinkCredit:{}, pendingSendsWaitingForCredit:{}, pendingSendsWaitingDelivery:{}", this.sendPath, this.sendLink.getName(), creditIssued, this.pendingSends.size(), this.pendingSendsData.size() - this.pendingSends.size()); this.linkCredit = this.linkCredit + creditIssued; this.sendWork.onEvent(); }
public void run() { if (!linkClose.isDone()) { Exception operationTimedout = new TimeoutException(String.format(Locale.US, "%s operation on Send Link(%s) timed out at %s", "Close", CoreMessageSender.this.sendLink.getName(), ZonedDateTime.now())); TRACE_LOGGER.warn(operationTimedout.getMessage()); ExceptionUtil.completeExceptionally(linkClose, operationTimedout, CoreMessageSender.this, true); } } }
@Override public void onLinkLocalOpen(Event event) { Link link = event.getLink(); if (link instanceof Sender) { Sender sender = (Sender) link; if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format("onLinkLocalOpen linkName[%s], localTarget[%s]", sender.getName(), sender.getTarget())); } } }
@Override public void onFlow(final int creditIssued) { synchronized (this.errorConditionLock) { this.lastKnownLinkError = null; } if (creditIssued <= 0) return; if (TRACE_LOGGER.isDebugEnabled()) { int numberOfSendsWaitingforCredit = this.pendingSends.size(); TRACE_LOGGER.debug(String.format(Locale.US, "clientId[%s], path[%s], linkName[%s], remoteLinkCredit[%s], pendingSendsWaitingForCredit[%s], pendingSendsWaitingDelivery[%s]", this.getClientId(), this.sendPath, this.sendLink.getName(), creditIssued, numberOfSendsWaitingforCredit, this.pendingSendsData.size() - numberOfSendsWaitingforCredit)); } this.sendWork.onEvent(); }
@Override public void onLinkRemoteOpen(Event event) { Link link = event.getLink(); if (link instanceof Sender) { Sender sender = (Sender) link; if (link.getRemoteTarget() != null) { if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format(Locale.US, "onLinkRemoteOpen linkName[%s], remoteTarget[%s]", sender.getName(), link.getRemoteTarget())); } synchronized (this.firstFlow) { this.isFirstFlow = false; this.msgSender.onOpenComplete(null); } } else { if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info( String.format(Locale.US, "onLinkRemoteOpen linkName[%s], remoteTarget[null], remoteSource[null], action[waitingForError]", sender.getName())); } } } }
@Override public void onLinkRemoteOpen(Event event) { Link link = event.getLink(); if (link != null && link instanceof Sender) { Sender sender = (Sender) link; if (link.getRemoteTarget() != null) { TRACE_LOGGER.debug("onLinkRemoteOpen: linkName:{}, remoteTarge:{}", sender.getName(), link.getRemoteTarget()); synchronized (this.firstFlow) { this.isFirstFlow = false; this.msgSender.onOpenComplete(null); } } else { TRACE_LOGGER.debug("onLinkRemoteOpen: linkName:{}, remoteTarget:{}, remoteSource:{}, action:{}", sender.getName(), null, null, "waitingForError"); } } }
public CompletableFuture<Collection<Message>> peekMessagesAsync(long fromSequenceNumber, int messageCount) { TRACE_LOGGER.debug("Peeking '{}' messages in '{}' from sequence number '{}'", messageCount, this.sendPath, fromSequenceNumber); return this.createRequestResponseLink().thenComposeAsync((v) -> { return CommonRequestResponseOperations.peekMessagesAsync(this.requestResponseLink, this.operationTimeout, fromSequenceNumber, messageCount, null, this.sendLink.getName()); }, MessagingFactory.INTERNAL_THREAD_POOL); } }
public void run() { if (!linkClose.isDone()) { final Sender link; synchronized (MessageSender.this.errorConditionLock) { link = MessageSender.this.sendLink; } final Exception operationTimedout = new TimeoutException(String.format(Locale.US, "Entity(%s): close operation timed out at %s", MessageSender.this.sendPath, ZonedDateTime.now())); if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info( String.format(Locale.US, "clientId[%s], message sender(linkName: %s, path: %s) close call timed out", MessageSender.this.getClientId(), link.getName(), MessageSender.this.sendPath), operationTimedout); } ExceptionUtil.completeExceptionally(linkClose, operationTimedout, MessageSender.this); MessageSender.this.onError((Exception) null); } } }
@Override public ErrorContext getContext() { final boolean isLinkOpened = this.linkFirstOpen != null && this.linkFirstOpen.isDone(); final String referenceId = this.sendLink != null && this.sendLink.getRemoteProperties() != null && this.sendLink.getRemoteProperties().containsKey(ClientConstants.TRACKING_ID_PROPERTY) ? this.sendLink.getRemoteProperties().get(ClientConstants.TRACKING_ID_PROPERTY).toString() : ((this.sendLink != null) ? this.sendLink.getName() : null); SenderErrorContext errorContext = new SenderErrorContext( this.underlyingFactory!=null ? this.underlyingFactory.getHostName() : null, this.sendPath, referenceId, isLinkOpened && this.sendLink != null ? this.sendLink.getCredit() : null); return errorContext; }
@Override public void onError(Exception exception) { if(!this.openFuture.isDone()) { this.onOpenComplete(exception); } if(this.getIsClosingOrClosed()) { if(!this.closeFuture.isDone()) { TRACE_LOGGER.error("Closing internal send link '{}' of requestresponselink to {} failed.", this.sendLink.getName(), this.parent.linkPath, exception); AsyncUtil.completeFutureExceptionally(this.closeFuture, exception); } } else { TRACE_LOGGER.warn("Internal send link '{}' of requestresponselink to '{}' encountered error.", this.sendLink.getName(), this.parent.linkPath, exception); this.parent.underlyingFactory.deregisterForConnectionError(this.sendLink); this.matchingReceiveLink.close(); this.parent.underlyingFactory.deregisterForConnectionError(this.matchingReceiveLink); this.parent.onInnerLinksClosed(this.linkGeneration, exception); } }
@Override public ErrorContext getContext() { final Sender link; synchronized (this.errorConditionLock) { link = this.sendLink; } final boolean isLinkOpened = this.linkFirstOpen != null && this.linkFirstOpen.isDone(); final String referenceId = link != null && link.getRemoteProperties() != null && link.getRemoteProperties().containsKey(ClientConstants.TRACKING_ID_PROPERTY) ? link.getRemoteProperties().get(ClientConstants.TRACKING_ID_PROPERTY).toString() : ((link != null) ? link.getName() : null); final SenderContext errorContext = new SenderContext( this.underlyingFactory != null ? this.underlyingFactory.getHostName() : null, this.sendPath, referenceId, isLinkOpened && link != null ? link.getCredit() : null); return errorContext; }
@Override public void inspectDeliveryUpdate(Sender sender, Delivery delivery) { if (delivery.remotelySettled()) { IntegrationTestLogger.LOGGER.trace("Remote settled message for sender: " + sender.getName()); settled.countDown(); } } });
@Override public void onLinkFlow(Event event) { if (this.isFirstFlow) { synchronized (this.firstFlow) { if (this.isFirstFlow) { this.msgSender.onOpenComplete(null); this.isFirstFlow = false; } } } Sender sender = event.getSender(); this.msgSender.onFlow(sender.getRemoteCredit()); if (TRACE_LOGGER.isDebugEnabled()) { TRACE_LOGGER.debug("onLinkFlow linkName[" + sender.getName() + "], unsettled[" + sender.getUnsettled() + "], credit[" + sender.getCredit() + "]"); } } }
@Override public void onOpenComplete(Exception completionException) { if(completionException == null) { TRACE_LOGGER.debug("Opened internal send link of requestresponselink to {}", parent.linkPath); this.maxMessageSize = Util.getMaxMessageSizeFromLink(this.sendLink); AsyncUtil.completeFuture(this.openFuture, null); this.runSendLoop(); } else { TRACE_LOGGER.error("Opening internal send link '{}' of requestresponselink to {} failed.", this.sendLink.getName(), this.parent.linkPath, completionException); this.setClosed(); AsyncUtil.completeFuture(this.closeFuture, null); AsyncUtil.completeFutureExceptionally(this.openFuture, completionException); } }
@Override public void onEvent() { if (InternalSender.this.sendLink != null && InternalSender.this.sendLink.getLocalState() != EndpointState.CLOSED) { TRACE_LOGGER.debug("Closing internal send link of requestresponselink to {}", RequestResponseLink.this.linkPath); InternalSender.this.sendLink.close(); InternalSender.this.parent.underlyingFactory.deregisterForConnectionError(InternalSender.this.sendLink); if(waitForCloseCompletion) { RequestResponseLink.scheduleLinkCloseTimeout(InternalSender.this.closeFuture, InternalSender.this.parent.underlyingFactory.getOperationTimeout(), InternalSender.this.sendLink.getName()); } else { AsyncUtil.completeFuture(InternalSender.this.closeFuture, null); } } } });
@Override public void onLinkFlow(Event event) { if (this.isFirstFlow) { synchronized (this.firstFlow) { if (this.isFirstFlow) { this.msgSender.onOpenComplete(null); this.isFirstFlow = false; } } } Sender sender = event.getSender(); this.msgSender.onFlow(sender.getRemoteCredit()); TRACE_LOGGER.debug("onLinkFlow: linkName:{}, unsettled:{}, credit:{}", sender.getName(), sender.getUnsettled(), sender.getCredit()); } }
@Override public void onDelivery(Event event) { Delivery delivery = event.getDelivery(); while (delivery != null) { Sender sender = (Sender) delivery.getLink(); if (TRACE_LOGGER.isTraceEnabled()) { TRACE_LOGGER.trace( "onDelivery linkName[" + sender.getName() + "], unsettled[" + sender.getUnsettled() + "], credit[" + sender.getRemoteCredit() + "], deliveryState[" + delivery.getRemoteState() + "], delivery.isBuffered[" + delivery.isBuffered() + "], delivery.id[" + new String(delivery.getTag()) + "]"); } msgSender.onSendComplete(delivery); delivery.settle(); delivery = sender.current(); } }
@Override public void onDelivery(Event event) { Delivery delivery = event.getDelivery(); while (delivery != null) { Sender sender = (Sender) delivery.getLink(); TRACE_LOGGER.debug("onDelivery: linkName:{}, unsettled:{}, credit:{}, deliveryState:{}, delivery.isBuffered:{}, delivery.tag:{}", sender.getName(), sender.getUnsettled(), sender.getRemoteCredit(), delivery.getRemoteState(), delivery.isBuffered(), delivery.getTag()); msgSender.onSendComplete(delivery); delivery.settle(); delivery = sender.current(); } }
@Override public void onResponse(AmqpProtocolConverter converter, Response response) throws IOException { if (consumerInfo.isDurable()) { RemoveSubscriptionInfo rsi = new RemoveSubscriptionInfo(); rsi.setConnectionId(session.getConnection().getConnectionId()); rsi.setSubscriptionName(getEndpoint().getName()); rsi.setClientId(session.getConnection().getClientId()); sendToActiveMQ(rsi); } session.unregisterSender(getConsumerId()); AmqpSender.super.close(); } });
@Override public void onResponse(AmqpProtocolConverter converter, Response response) throws IOException { if (consumerInfo.isDurable()) { RemoveSubscriptionInfo rsi = new RemoveSubscriptionInfo(); rsi.setConnectionId(session.getConnection().getConnectionId()); rsi.setSubscriptionName(getEndpoint().getName()); rsi.setClientId(session.getConnection().getClientId()); sendToActiveMQ(rsi); } session.unregisterSender(getConsumerId()); AmqpSender.super.close(); } });