Java Code Examples for org.apache.qpid.proton.engine.Delivery#isPartial()
The following examples show how to use
org.apache.qpid.proton.engine.Delivery#isPartial() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Server.java From qpid-proton-j with Apache License 2.0 | 6 votes |
@Override public void onDelivery(Event evt) { Delivery dlv = evt.getDelivery(); Link link = dlv.getLink(); if (link instanceof Sender) { dlv.settle(); } else { Receiver rcv = (Receiver) link; if (!dlv.isPartial()) { byte[] bytes = new byte[dlv.pending()]; rcv.recv(bytes, 0, bytes.length); String address = router.getAddress(rcv); Message message = new Message(bytes); messages.put(address, message); dlv.disposition(Accepted.getInstance()); dlv.settle(); if (!quiet) { System.out.println(String.format("Got message(%s): %s", address, message)); } send(address); } } }
Example 2
Source File: Drain.java From qpid-proton-j with Apache License 2.0 | 6 votes |
@Override public void onDelivery(Event evt) { Delivery dlv = evt.getDelivery(); if (dlv.getLink() instanceof Receiver) { Receiver receiver = (Receiver) dlv.getLink(); if (!dlv.isPartial()) { byte[] bytes = new byte[dlv.pending()]; receiver.recv(bytes, 0, bytes.length); Message msg = new Message(bytes); if (!quiet) { System.out.println(String.format("Got message: %s", msg)); } received++; dlv.settle(); } if ((received >= count) || (!block && !receiver.draining())) { receiver.getSession().getConnection().close(); } } }
Example 3
Source File: Recv.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Override public void onDelivery(Event event) { Receiver recv = (Receiver)event.getLink(); Delivery delivery = recv.current(); if (delivery.isReadable() && !delivery.isPartial()) { int size = delivery.pending(); byte[] buffer = new byte[size]; int read = recv.recv(buffer, 0, buffer.length); recv.advance(); Message msg = Proton.message(); msg.decode(buffer, 0, read); System.out.println(((AmqpValue)msg.getBody()).getValue()); } }
Example 4
Source File: ReactorTest.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Override public void onDelivery(Event event) { Delivery dlv = event.getDelivery(); if (!dlv.isPartial()) { dlv.settle(); ++received; } }
Example 5
Source File: AmqpReceiver.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public void processDeliveryUpdates(AmqpConnection connection, Delivery delivery) throws IOException { Delivery incoming = null; do { incoming = getEndpoint().current(); if (incoming != null) { if (incoming.isReadable() && !incoming.isPartial()) { LOG.trace("{} has incoming Message(s).", this); try { processDelivery(incoming); } catch (Exception e) { throw IOExceptionSupport.create(e); } getEndpoint().advance(); } else { LOG.trace("{} has a partial incoming Message(s), deferring.", this); incoming = null; } } else { // 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; } } } } while (incoming != null); super.processDeliveryUpdates(connection, delivery); }
Example 6
Source File: AmqpConsumer.java From qpid-jms with Apache License 2.0 | 5 votes |
@Override public void processDeliveryUpdates(AmqpProvider provider, Delivery delivery) throws ProviderException { if(delivery.getDefaultDeliveryState() == null){ delivery.setDefaultDeliveryState(Released.getInstance()); } 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 ProviderExceptionSupport.createNonFatalOrPassthrough(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); }
Example 7
Source File: ProtonServerReceiverContext.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Override public void onMessage(Delivery delivery) throws ActiveMQAMQPException { connection.requireInHandler(); Receiver receiver = ((Receiver) delivery.getLink()); if (receiver.current() != delivery) { return; } try { if (delivery.isAborted()) { clearLargeMessage(); // Aborting implicitly remotely settles, so advance // receiver to the next delivery and settle locally. receiver.advance(); delivery.settle(); // Replenish the credit if not doing a drain if (!receiver.getDrain()) { receiver.flow(1); } return; } else if (delivery.isPartial()) { if (sessionSPI.getStorageManager() instanceof NullStorageManager) { // if we are dealing with the NullStorageManager we should just make it a regular message anyways return; } if (currentLargeMessage == null) { // minLargeMessageSize < 0 means no large message treatment, make it disabled if (minLargeMessageSize > 0 && delivery.available() >= minLargeMessageSize) { initializeCurrentLargeMessage(delivery, receiver); } } else { currentLargeMessage.addBytes(receiver.recv()); } return; } AMQPMessage message; // this is treating the case where the frameSize > minLargeMessage and the message is still large enough if (!(sessionSPI.getStorageManager() instanceof NullStorageManager) && currentLargeMessage == null && minLargeMessageSize > 0 && delivery.available() >= minLargeMessageSize) { initializeCurrentLargeMessage(delivery, receiver); } if (currentLargeMessage != null) { currentLargeMessage.addBytes(receiver.recv()); receiver.advance(); currentLargeMessage.finishParse(); message = currentLargeMessage; currentLargeMessage = null; } else { ReadableBuffer data = receiver.recv(); receiver.advance(); message = sessionSPI.createStandardMessage(delivery, data); } Transaction tx = null; if (delivery.getRemoteState() instanceof TransactionalState) { TransactionalState txState = (TransactionalState) delivery.getRemoteState(); tx = this.sessionSPI.getTransaction(txState.getTxnId(), false); } actualDelivery(message, delivery, receiver, tx); } catch (Exception e) { throw new ActiveMQAMQPInternalErrorException(e.getMessage(), e); } }
Example 8
Source File: ProtonReceiverImpl.java From vertx-proton with Apache License 2.0 | 4 votes |
void onDelivery() { if (this.handler == null) { return; } Receiver receiver = getReceiver(); Delivery delivery = receiver.current(); if (delivery != null) { if(delivery.isAborted()) { handleAborted(receiver, delivery); return; } if (delivery.isPartial()) { handlePartial(receiver, delivery); // Delivery is not yet completely received, // return and allow further frames to arrive. return; } // Complete prior partial content if needed, or grab it all. ReadableBuffer data = receiver.recv(); if(splitContent != null) { data = completePartial(data); } receiver.advance(); MessageImpl msg = (MessageImpl) Proton.message(); ProtonDeliveryImpl delImpl = new ProtonDeliveryImpl(delivery); try { msg.decode(data); } catch (Throwable t) { LOG.debug("Unable to decode message, undeliverable", t); handleDecodeFailure(receiver, delImpl); return; } handler.handle(delImpl, msg); if (autoAccept && delivery.getLocalState() == null) { accepted(delImpl, true); } if (prefetch > 0) { // Replenish credit if prefetch is configured. // TODO: batch credit replenish, optionally flush if exceeding a given threshold? flow(1, false); } else { processForDrainCompletion(); } } }