private void drainInbound() { while( deliveryListener!=null && !inbound.isEmpty() && resumed>0) { deliveryListener.onMessageDelivery(inbound.removeFirst()); receiver.flow(1); } }
private void topup(Receiver link, int window) { int delta = window - link.getCredit(); link.flow(delta); }
/** * Provide the receiver endpoint with the given amount of credits. * * @param credits * the credit value to pass on to the wrapped Receiver. */ public void flow(int credits) { getEndpoint().flow(credits); }
/** * Provide the receiver endpoint with the given amount of credits. * * @param credits * the credit value to pass on to the wrapped Receiver. */ public void flow(int credits) { getEndpoint().flow(credits); }
private void topup(Receiver link, int window) { int delta = window - link.getCredit(); link.flow(delta); }
private void flow(int credits, boolean checkPrefetch) throws IllegalStateException { if (checkPrefetch && prefetch > 0) { throw new IllegalStateException("Manual credit management not available while prefetch is non-zero"); } if (drainCompleteHandler != null) { throw new IllegalStateException("A previous drain operation has not yet completed"); } getReceiver().flow(credits); flushConnection(); }
private void sendFlow(int credits) { if(!this.isBrowsableSession && credits > 0) { this.receiveLink.flow(credits); TRACE_LOGGER.debug("Sent flow to the service. receiverPath:{}, linkname:{}, updated-link-credit:{}, sentCredits:{}", this.receivePath, this.receiveLink.getName(), this.receiveLink.getCredit(), credits); } }
private void sendFlow(final int credits) { // slow down sending the flow - to make the protocol less-chat'y this.nextCreditToFlow += credits; if (this.shouldSendFlow()) { final int tempFlow = this.nextCreditToFlow; this.receiveLink.flow(tempFlow); this.nextCreditToFlow = 0; if (TRACE_LOGGER.isDebugEnabled()) { TRACE_LOGGER.debug(String.format("clientId[%s], receiverPath[%s], linkName[%s], updated-link-credit[%s], sentCredits[%s], ThreadId[%s]", this.getClientId(), this.receivePath, this.receiveLink.getName(), this.receiveLink.getCredit(), tempFlow, Thread.currentThread().getId())); } } }
private void sendFlowForNoPrefetchListener() { int currentCredit = getEndpoint().getCredit(); if (currentCredit < 1) { int additionalCredit = 1 - currentCredit; LOG.trace("Consumer {} granting additional credit: {}", getConsumerId(), additionalCredit); getEndpoint().flow(additionalCredit); } }
private void sendFlowForNoPrefetchListener() { int currentCredit = getEndpoint().getCredit(); if (currentCredit < 1) { int additionalCredit = 1 - currentCredit; LOG.trace("Consumer {} granting additional credit: {}", getConsumerId(), additionalCredit); getEndpoint().flow(additionalCredit); } }
public void addTransactionHandler(Coordinator coordinator, Receiver receiver) { ProtonTransactionHandler transactionHandler = new ProtonTransactionHandler(sessionSPI); receiver.setContext(transactionHandler); receiver.open(); receiver.flow(100); }
public void flow(int credits, int threshold) { // Use the SessionSPI to allocate producer credits, or default, always allocate credit. if (sessionSPI != null) { sessionSPI.offerProducerCredit(address, credits, threshold, receiver); } else { synchronized (connection.getLock()) { receiver.flow(credits); connection.flush(); } } }
@Override public void run() { checkClosed(); try { getEndpoint().flow(credit); if (!deferWrite) { session.pumpToProtonTransport(request); } request.onSuccess(); } catch (Exception e) { request.onFailure(e); } } });
@Override public void atomicRun() { connection.lock(); try { if (receiver.getCredit() <= threshold) { int topUp = refill - receiver.getCredit(); if (topUp > 0) { receiver.flow(topUp); } } } finally { connection.unlock(); } connection.flush(); } };
protected void deliveryFailed(Delivery incoming, boolean expandCredit) { Modified disposition = new Modified(); disposition.setUndeliverableHere(true); disposition.setDeliveryFailed(true); incoming.disposition(disposition); incoming.settle(); if (expandCredit) { getEndpoint().flow(1); } }
public AmqpReceiver createReceiver(Source source, QoS qos, int prefetch, String name) { assertExecuting(); Receiver receiver = session.receiver(name); receiver.setSource(source); // Target target = new Target(); // target.setAddress(UUID.randomUUID().toString()); // receiver.setTarget(target); receiver.flow(prefetch); configureQos(receiver, qos); receiver.open(); pumpOut(); return new AmqpReceiver(this, receiver, qos); }
private void replenishCredit() { if (getEndpoint().getCredit() <= (getConfiguredReceiverCredit() * .2)) { LOG.debug("Sending more credit ({}) to transaction coordinator on session {}", getConfiguredReceiverCredit() - getEndpoint().getCredit(), session.getSessionId()); getEndpoint().flow(getConfiguredReceiverCredit() - getEndpoint().getCredit()); session.pumpProtonToSocket(); } }
private void replenishCredit() { if (getEndpoint().getCredit() <= (getConfiguredReceiverCredit() * .2)) { LOG.debug("Sending more credit ({}) to transaction coordinator on session {}", getConfiguredReceiverCredit() - getEndpoint().getCredit(), session.getSessionId()); getEndpoint().flow(getConfiguredReceiverCredit() - getEndpoint().getCredit()); session.pumpProtonToSocket(); } }
public void addTransactionHandler(Coordinator coordinator, Receiver receiver) { ProtonTransactionHandler transactionHandler = new ProtonTransactionHandler(sessionSPI, connection); coordinator.setCapabilities(Symbol.getSymbol("amqp:local-transactions"), Symbol.getSymbol("amqp:multi-txns-per-ssn"), Symbol.getSymbol("amqp:multi-ssns-per-txn")); receiver.setContext(transactionHandler); connection.lock(); try { receiver.open(); receiver.flow(connection.getAmqpCredits()); } finally { connection.unlock(); } }
public void addTransactionHandler(Coordinator coordinator, Receiver receiver) { ProtonTransactionHandler transactionHandler = new ProtonTransactionHandler(sessionSPI, connection); coordinator.setCapabilities(Symbol.getSymbol("amqp:local-transactions"), Symbol.getSymbol("amqp:multi-txns-per-ssn"), Symbol.getSymbol("amqp:multi-ssns-per-txn")); receiver.setContext(transactionHandler); connection.runNow(() -> { receiver.open(); receiver.flow(connection.getAmqpCredits()); connection.flush(); }); }