@Override public synchronized void addPendingConfirm(Listener listener, long seq, PendingConfirm pendingConfirm) { SortedMap<Long, PendingConfirm> pendingConfirmsForListener = this.pendingConfirms.get(listener); Assert.notNull(pendingConfirmsForListener, "Listener not registered: " + listener + " " + this.pendingConfirms.keySet()); pendingConfirmsForListener.put(seq, pendingConfirm); this.listenerForSeq.put(seq, listener); if (pendingConfirm.getCorrelationData() != null) { String returnCorrelation = pendingConfirm.getCorrelationData().getId(); // NOSONAR never null if (StringUtils.hasText(returnCorrelation)) { this.pendingReturns.put(returnCorrelation, pendingConfirm); } } }
@Override public synchronized void addPendingConfirm(Listener listener, long seq, PendingConfirm pendingConfirm) { SortedMap<Long, PendingConfirm> pendingConfirmsForListener = this.pendingConfirms.get(listener); Assert.notNull(pendingConfirmsForListener, "Listener not registered: " + listener + " " + this.pendingConfirms.keySet()); pendingConfirmsForListener.put(seq, pendingConfirm); this.listenerForSeq.put(seq, listener); if (pendingConfirm.getCorrelationData() != null) { String returnCorrelation = pendingConfirm.getCorrelationData().getId(); // NOSONAR never null if (StringUtils.hasText(returnCorrelation)) { this.pendingReturns.put(returnCorrelation, pendingConfirm); } } }
/** * Gets unconfirmed correlation data older than age and removes them. * @param age in milliseconds * @return the collection of correlation data for which confirms have * not been received or null if no such confirms exist. */ @Nullable public Collection<CorrelationData> getUnconfirmed(long age) { Set<CorrelationData> unconfirmed = new HashSet<>(); long cutoffTime = System.currentTimeMillis() - age; for (Channel channel : this.publisherConfirmChannels.keySet()) { Collection<PendingConfirm> confirms = ((PublisherCallbackChannel) channel).expire(this, cutoffTime); for (PendingConfirm confirm : confirms) { unconfirmed.add(confirm.getCorrelationData()); } } return unconfirmed.size() > 0 ? unconfirmed : null; }
/** * Gets unconfirmed correlation data older than age and removes them. * @param age in milliseconds * @return the collection of correlation data for which confirms have * not been received or null if no such confirms exist. */ @Nullable public Collection<CorrelationData> getUnconfirmed(long age) { Set<CorrelationData> unconfirmed = new HashSet<>(); long cutoffTime = System.currentTimeMillis() - age; for (Channel channel : this.publisherConfirmChannels.keySet()) { Collection<PendingConfirm> confirms = ((PublisherCallbackChannel) channel).expire(this, cutoffTime); for (PendingConfirm confirm : confirms) { unconfirmed.add(confirm.getCorrelationData()); } } return unconfirmed.size() > 0 ? unconfirmed : null; }
@Override public void handleConfirm(PendingConfirm pendingConfirm, boolean ack) { if (this.confirmCallback != null) { this.confirmCallback.confirm(pendingConfirm.getCorrelationData(), ack, pendingConfirm.getCause()); // NOSONAR never null } }
@Override public void handleConfirm(PendingConfirm pendingConfirm, boolean ack) { if (this.confirmCallback != null) { this.confirmCallback.confirm(pendingConfirm.getCorrelationData(), ack, pendingConfirm.getCause()); // NOSONAR never null } }
@Override public synchronized Collection<PendingConfirm> expire(Listener listener, long cutoffTime) { SortedMap<Long, PendingConfirm> pendingConfirmsForListener = this.pendingConfirms.get(listener); if (pendingConfirmsForListener == null) { return Collections.<PendingConfirm>emptyList(); } else { List<PendingConfirm> expired = new ArrayList<PendingConfirm>(); Iterator<Entry<Long, PendingConfirm>> iterator = pendingConfirmsForListener.entrySet().iterator(); while (iterator.hasNext()) { PendingConfirm pendingConfirm = iterator.next().getValue(); if (pendingConfirm.getTimestamp() < cutoffTime) { expired.add(pendingConfirm); iterator.remove(); CorrelationData correlationData = pendingConfirm.getCorrelationData(); if (correlationData != null && StringUtils.hasText(correlationData.getId())) { this.pendingReturns.remove(correlationData.getId()); // NOSONAR never null } } else { break; } } return expired; } }
@Override public synchronized Collection<PendingConfirm> expire(Listener listener, long cutoffTime) { SortedMap<Long, PendingConfirm> pendingConfirmsForListener = this.pendingConfirms.get(listener); if (pendingConfirmsForListener == null) { return Collections.<PendingConfirm>emptyList(); } else { List<PendingConfirm> expired = new ArrayList<PendingConfirm>(); Iterator<Entry<Long, PendingConfirm>> iterator = pendingConfirmsForListener.entrySet().iterator(); while (iterator.hasNext()) { PendingConfirm pendingConfirm = iterator.next().getValue(); if (pendingConfirm.getTimestamp() < cutoffTime) { expired.add(pendingConfirm); iterator.remove(); CorrelationData correlationData = pendingConfirm.getCorrelationData(); if (correlationData != null && StringUtils.hasText(correlationData.getId())) { this.pendingReturns.remove(correlationData.getId()); // NOSONAR never null } } else { break; } } return expired; } }
Entry<Long, PendingConfirm> entry = iterator.next(); PendingConfirm value = entry.getValue(); CorrelationData correlationData = value.getCorrelationData(); if (correlationData != null) { correlationData.getFuture().set(new Confirm(ack, value.getCause()));
Entry<Long, PendingConfirm> entry = iterator.next(); PendingConfirm value = entry.getValue(); CorrelationData correlationData = value.getCorrelationData(); if (correlationData != null) { correlationData.getFuture().set(new Confirm(ack, value.getCause()));
MessageProperties messageProperties = converter.toMessageProperties(properties, new Envelope(0L, false, exchange, routingKey), StandardCharsets.UTF_8.name()); if (confirm.getCorrelationData() != null) { confirm.getCorrelationData().setReturnedMessage(new Message(body, messageProperties)); // NOSONAR never null
MessageProperties messageProperties = converter.toMessageProperties(properties, new Envelope(0L, false, exchange, routingKey), StandardCharsets.UTF_8.name()); if (confirm.getCorrelationData() != null) { confirm.getCorrelationData().setReturnedMessage(new Message(body, messageProperties)); // NOSONAR never null
CorrelationData correlationData = pendingConfirm.getCorrelationData(); if (correlationData != null) { correlationData.getFuture().set(new Confirm(ack, pendingConfirm.getCause()));
CorrelationData correlationData = pendingConfirm.getCorrelationData(); if (correlationData != null) { correlationData.getFuture().set(new Confirm(ack, pendingConfirm.getCause()));