@Override public void run() { LOG.trace("Receiver {} running scheduled stop", this); if (getEndpoint().getRemoteCredit() != 0) { stop(request); session.pumpToProtonTransport(request); } } }, timeout, TimeUnit.MILLISECONDS);
@Override public void processFlowUpdates(AmqpProvider provider) throws IOException { // Check if we tried to stop and have now run out of credit, and // processed all locally queued messages if (stopRequest != null) { Receiver receiver = getEndpoint(); if (receiver.getRemoteCredit() <= 0 && receiver.getQueued() == 0) { stopRequest.onSuccess(); stopRequest = null; } } if (pullRequest != null) { Receiver receiver = getEndpoint(); if (receiver.getRemoteCredit() <= 0 && receiver.getQueued() == 0) { pullRequest.onSuccess(); pullRequest = null; } } LOG.trace("Consumer {} flow updated, remote credit = {}", getConsumerId(), getEndpoint().getRemoteCredit()); super.processFlowUpdates(provider); }
@Override public void processFlowUpdates(AmqpConnection connection) throws IOException { if (pullRequest != null || stopRequest != null) { Receiver receiver = getEndpoint(); if (receiver.getRemoteCredit() <= 0 && receiver.getQueued() == 0) { if (pullRequest != null) { pullRequest.onSuccess(); pullRequest = null; } if (stopRequest != null) { stopRequest.onSuccess(); stopRequest = null; } } } LOG.trace("Consumer {} flow updated, remote credit = {}", getSubscriptionName(), getEndpoint().getRemoteCredit()); super.processFlowUpdates(connection); }
@Override public void processFlowUpdates(AmqpProvider provider) throws IOException { // Check if we tried to stop and have now run out of credit, and // processed all locally queued messages if (stopRequest != null) { Receiver receiver = getEndpoint(); if (receiver.getRemoteCredit() <= 0 && receiver.getQueued() == 0) { stopRequest.onSuccess(); stopRequest = null; } } if (pullRequest != null) { Receiver receiver = getEndpoint(); if (receiver.getRemoteCredit() <= 0 && receiver.getQueued() == 0) { pullRequest.onSuccess(); pullRequest = null; } } LOG.trace("Consumer {} flow updated, remote credit = {}", getConsumerId(), getEndpoint().getRemoteCredit()); super.processFlowUpdates(provider); }
private void stopOnSchedule(long timeout, final AsyncResult request) { LOG.trace("Consumer {} scheduling stop", getConsumerId()); // We need to drain the credit if no message(s) arrive to use it. final ScheduledFuture<?> future = getSession().schedule(() -> { LOG.trace("Consumer {} running scheduled stop", getConsumerId()); if (getEndpoint().getRemoteCredit() != 0) { stop(request); session.getProvider().pumpToProtonTransport(request); } }, timeout); stopRequest = new ScheduledRequest(future, request); }
if (receiver.getRemoteCredit() < lo_thresh) final int more = Math.min(_credit, max - receiver.getRemoteCredit()); _credit -= more; _distributed += more; if (receiver.getRemoteCredit() == 0 && _credited.contains(receiver))
if (receiver.getRemoteCredit() < lo_thresh) final int more = Math.min(_credit, max - receiver.getRemoteCredit()); _credit -= more; _distributed += more; if (receiver.getRemoteCredit() == 0 && _credited.contains(receiver))
private void stopOnSchedule(long timeout, final AsyncResult request) { LOG.trace("Consumer {} scheduling stop", getConsumerId()); // We need to drain the credit if no message(s) arrive to use it. final ScheduledFuture<?> future = getSession().schedule(() -> { LOG.trace("Consumer {} running scheduled stop", getConsumerId()); if (getEndpoint().getRemoteCredit() != 0) { stop(request); session.getProvider().pumpToProtonTransport(request); } }, timeout); stopRequest = new ScheduledRequest(future, request); }
? String.format(Locale.US, "onDelivery linkName[%s], updatedLinkCredit[%s], remoteCredit[%s], " + "remoteCondition[%s], delivery.isSettled[%s]", receiveLink.getName(), receiveLink.getCredit(), receiveLink.getRemoteCredit(), receiveLink.getRemoteCondition(), delivery.isSettled()) : String.format(Locale.US, "delivery.isSettled[%s]", delivery.isSettled())); String.format(Locale.US, "onDelivery linkName[%s], updatedLinkCredit[%s], remoteCredit[%s], " + "remoteCondition[%s], delivery.isPartial[%s]", receiveLink.getName(), receiveLink.getCredit(), receiveLink.getRemoteCredit(), receiveLink.getRemoteCondition(), delivery.isPartial()));
needed -= link.getRemoteCredit(); _draining++;
@Override public void onDelivery(Event event) { synchronized (this.firstResponse) { if (this.isFirstResponse) { this.isFirstResponse = false; this.amqpReceiver.onOpenComplete(null); } } Delivery delivery = event.getDelivery(); Receiver receiveLink = (Receiver) delivery.getLink(); TRACE_LOGGER.debug("onDelivery: linkName:{}, updatedLinkCredit:{}, remoteCredit:{}, remoteCondition:{}, delivery.isPartial:{}", receiveLink.getName(), receiveLink.getCredit(), receiveLink.getRemoteCredit(), receiveLink.getRemoteCondition(), delivery.isPartial()); //TODO: What happens when a delivery has no message, but only disposition from the remote link? Like when ServiceBus service sends just a disposition to the receiver?" // If a message spans across deliveries (for ex: 200k message will be 4 frames (deliveries) 64k 64k 64k 8k), // all until "last-1" deliveries will be partial // reactor will raise onDelivery event for all of these - we only need the last one if (!delivery.isPartial()) { this.amqpReceiver.onReceiveComplete(delivery); } } }
if (getEndpoint().getRemoteCredit() <= 0) { if (stopRequest != null) { stopRequest.onSuccess();
private void stop(final AsyncResult request) { Receiver receiver = getEndpoint(); if (receiver.getRemoteCredit() <= 0) { if (receiver.getQueued() == 0) {
@Override public void processDeliveryUpdates(AmqpProvider provider, Delivery delivery) throws IOException { if (delivery.isReadable() && !delivery.isPartial()) { LOG.trace("{} has incoming Message(s).", this); try { if (processDelivery(delivery)) { // We processed a message, signal completion // of a message pull request if there is one. if (pullRequest != null) { pullRequest.onSuccess(); pullRequest = null; } } } catch (Exception e) { throw IOExceptionSupport.create(e); } } if (getEndpoint().current() == null) { // We have exhausted the locally queued messages on this link. // Check if we tried to stop and have now run out of credit. if (getEndpoint().getRemoteCredit() <= 0) { if (stopRequest != null) { stopRequest.onSuccess(); stopRequest = null; } } } super.processDeliveryUpdates(provider, delivery); }
@Override public void processDeliveryUpdates(AmqpProvider provider, Delivery delivery) throws IOException { if (delivery.isReadable() && !delivery.isPartial()) { LOG.trace("{} has incoming Message(s).", this); try { if (processDelivery(delivery)) { // We processed a message, signal completion // of a message pull request if there is one. if (pullRequest != null) { pullRequest.onSuccess(); pullRequest = null; } } } catch (Exception e) { throw IOExceptionSupport.create(e); } } if (getEndpoint().current() == null) { // We have exhausted the locally queued messages on this link. // Check if we tried to stop and have now run out of credit. if (getEndpoint().getRemoteCredit() <= 0) { if (stopRequest != null) { stopRequest.onSuccess(); stopRequest = null; } } } super.processDeliveryUpdates(provider, delivery); }
if (receiver.getRemoteCredit() <= 0) { if (receiver.getQueued() == 0) {
assertEquals(0, queueView.getDeliveringCount()); assertEquals(10, receiver.getReceiver().getRemoteCredit()); assertEquals(0, receiver.getReceiver().getRemoteCredit()); assertEquals(0, receiver.getReceiver().getRemoteCredit());
if (receiver.getRemoteCredit() <= 0) { if (receiver.getQueued() == 0) {
private void doTestPullWithNoMessageGetDrained(boolean topic) throws Exception { final String destinationName; if (topic) { destinationName = getTopicName(); } else { destinationName = getQueueName(); } AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect()); AmqpSession session = connection.createSession(); AmqpReceiver receiver = session.createReceiver(destinationName); receiver.flow(10); Queue queueView = getProxyToQueue(destinationName); assertEquals(0, queueView.getMessageCount()); assertEquals(0, queueView.getMessagesAcknowledged()); assertEquals(10, receiver.getReceiver().getRemoteCredit()); assertNull(receiver.pull(1, TimeUnit.SECONDS)); assertEquals(0, receiver.getReceiver().getRemoteCredit()); connection.close(); }
private void doTestPullOneFromRemote(boolean topic) throws Exception { AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect()); AmqpSession session = connection.createSession(); final String destinationName; if (topic) { destinationName = getTopicName(); } else { destinationName = getQueueName(); } AmqpReceiver receiver = session.createReceiver(destinationName); int MSG_COUNT = 20; sendMessages(destinationName, MSG_COUNT); Queue queueView = getProxyToQueue(destinationName); assertEquals(MSG_COUNT, queueView.getMessageCount()); assertEquals(0, queueView.getDeliveringCount()); assertEquals(0, receiver.getReceiver().getRemoteCredit()); AmqpMessage message = receiver.pull(5, TimeUnit.SECONDS); assertNotNull(message); message.accept(); assertEquals(0, receiver.getReceiver().getRemoteCredit()); receiver.close(); connection.close(); }