Search in sources :

Example 1 with Modified

use of org.apache.qpid.proton.amqp.messaging.Modified in project vertx-proton by vert-x3.

the class ProtonHelper method modified.

/**
 * Modify the given delivery by applying Modified disposition state, with deliveryFailed and underliverableHere flags
 * as given, and optionally settling.
 *
 * @param delivery
 *          the delivery to update
 * @param settle
 *          whether to settle
 * @param deliveryFailed
 *          whether the delivery should be treated as failed
 * @param undeliverableHere
 *          whether the delivery is considered undeliverable by the related receiver
 * @return the delivery
 */
public static ProtonDelivery modified(ProtonDelivery delivery, boolean settle, boolean deliveryFailed, boolean undeliverableHere) {
    Modified modified = new Modified();
    modified.setDeliveryFailed(deliveryFailed);
    modified.setUndeliverableHere(undeliverableHere);
    delivery.disposition(modified, settle);
    return delivery;
}
Also used : Modified(org.apache.qpid.proton.amqp.messaging.Modified)

Example 2 with Modified

use of org.apache.qpid.proton.amqp.messaging.Modified in project activemq-artemis by apache.

the class AmqpReceiver method configureSource.

protected void configureSource(Source source) {
    Map<Symbol, DescribedType> filters = new HashMap<>();
    Symbol[] outcomes = new Symbol[] { Accepted.DESCRIPTOR_SYMBOL, Rejected.DESCRIPTOR_SYMBOL, Released.DESCRIPTOR_SYMBOL, Modified.DESCRIPTOR_SYMBOL };
    if (getSubscriptionName() != null && !getSubscriptionName().isEmpty()) {
        source.setExpiryPolicy(TerminusExpiryPolicy.NEVER);
        source.setDurable(TerminusDurability.UNSETTLED_STATE);
        source.setDistributionMode(COPY);
    } else {
        source.setDurable(TerminusDurability.NONE);
        source.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
    }
    source.setOutcomes(outcomes);
    Modified modified = new Modified();
    modified.setDeliveryFailed(true);
    modified.setUndeliverableHere(false);
    source.setDefaultOutcome(modified);
    if (isNoLocal()) {
        filters.put(NO_LOCAL_NAME, AmqpNoLocalFilter.NO_LOCAL);
    }
    if (getSelector() != null && !getSelector().trim().equals("")) {
        filters.put(JMS_SELECTOR_NAME, new AmqpJmsSelectorFilter(getSelector()));
    }
    if (!filters.isEmpty()) {
        source.setFilter(filters);
    }
}
Also used : DescribedType(org.apache.qpid.proton.amqp.DescribedType) Modified(org.apache.qpid.proton.amqp.messaging.Modified) HashMap(java.util.HashMap) Symbol(org.apache.qpid.proton.amqp.Symbol)

Example 3 with Modified

use of org.apache.qpid.proton.amqp.messaging.Modified in project activemq-artemis by apache.

the class AmqpReceiver method deliveryFailed.

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);
    }
}
Also used : Modified(org.apache.qpid.proton.amqp.messaging.Modified)

Example 4 with Modified

use of org.apache.qpid.proton.amqp.messaging.Modified in project activemq-artemis by apache.

the class AmqpReceiver method modified.

/**
 * Mark a message that was dispatched under the given Delivery instance as Modified.
 *
 * @param delivery
 *        the Delivery instance to mark modified.
 * @param deliveryFailed
 *        indicates that the delivery failed for some reason.
 * @param undeliverableHere
 *        marks the delivery as not being able to be process by link it was sent to.
 * @throws IOException
 *         if an error occurs while sending the reject.
 */
public void modified(final Delivery delivery, final Boolean deliveryFailed, final Boolean undeliverableHere) throws IOException {
    checkClosed();
    if (delivery == null) {
        throw new IllegalArgumentException("Delivery to reject cannot be null");
    }
    final ClientFuture request = new ClientFuture();
    session.getScheduler().execute(new Runnable() {

        @Override
        public void run() {
            checkClosed();
            try {
                if (!delivery.isSettled()) {
                    Modified disposition = new Modified();
                    disposition.setUndeliverableHere(undeliverableHere);
                    disposition.setDeliveryFailed(deliveryFailed);
                    delivery.disposition(disposition);
                    delivery.settle();
                    session.pumpToProtonTransport(request);
                }
                request.onSuccess();
            } catch (Exception e) {
                request.onFailure(e);
            }
        }
    });
    request.sync();
}
Also used : Modified(org.apache.qpid.proton.amqp.messaging.Modified) ClientFuture(org.apache.activemq.transport.amqp.client.util.ClientFuture) JmsOperationTimedOutException(org.apache.qpid.jms.JmsOperationTimedOutException) InvalidDestinationException(javax.jms.InvalidDestinationException) IOException(java.io.IOException)

Example 5 with Modified

use of org.apache.qpid.proton.amqp.messaging.Modified in project activemq-artemis by apache.

the class AmqpSender method processDeliveryUpdates.

@Override
public void processDeliveryUpdates(AmqpConnection connection, Delivery updated) throws IOException {
    List<Delivery> toRemove = new ArrayList<>();
    for (Delivery delivery : pending) {
        DeliveryState state = delivery.getRemoteState();
        if (state == null) {
            continue;
        }
        doDeliveryUpdateInspection(delivery);
        Outcome outcome = null;
        if (state instanceof TransactionalState) {
            LOG.trace("State of delivery is Transactional, retrieving outcome: {}", state);
            outcome = ((TransactionalState) state).getOutcome();
        } else if (state instanceof Outcome) {
            outcome = (Outcome) state;
        } else {
            LOG.warn("Message send updated with unsupported state: {}", state);
            outcome = null;
        }
        AsyncResult request = (AsyncResult) delivery.getContext();
        Exception deliveryError = null;
        if (outcome instanceof Accepted) {
            LOG.trace("Outcome of delivery was accepted: {}", delivery);
            if (request != null && !request.isComplete()) {
                request.onSuccess();
            }
        } else if (outcome instanceof Rejected) {
            LOG.trace("Outcome of delivery was rejected: {}", delivery);
            ErrorCondition remoteError = ((Rejected) outcome).getError();
            if (remoteError == null) {
                remoteError = getEndpoint().getRemoteCondition();
            }
            deliveryError = AmqpSupport.convertToException(remoteError);
        } else if (outcome instanceof Released) {
            LOG.trace("Outcome of delivery was released: {}", delivery);
            deliveryError = new IOException("Delivery failed: released by receiver");
        } else if (outcome instanceof Modified) {
            LOG.trace("Outcome of delivery was modified: {}", delivery);
            deliveryError = new IOException("Delivery failed: failure at remote");
        }
        if (deliveryError != null) {
            if (request != null && !request.isComplete()) {
                request.onFailure(deliveryError);
            } else {
                connection.fireClientException(deliveryError);
            }
        }
        tagGenerator.returnTag(delivery.getTag());
        delivery.settle();
        toRemove.add(delivery);
    }
    pending.removeAll(toRemove);
}
Also used : Released(org.apache.qpid.proton.amqp.messaging.Released) Modified(org.apache.qpid.proton.amqp.messaging.Modified) ErrorCondition(org.apache.qpid.proton.amqp.transport.ErrorCondition) ArrayList(java.util.ArrayList) Rejected(org.apache.qpid.proton.amqp.messaging.Rejected) IOException(java.io.IOException) InvalidDestinationException(javax.jms.InvalidDestinationException) IOException(java.io.IOException) Accepted(org.apache.qpid.proton.amqp.messaging.Accepted) TransactionalState(org.apache.qpid.proton.amqp.transaction.TransactionalState) DeliveryState(org.apache.qpid.proton.amqp.transport.DeliveryState) Outcome(org.apache.qpid.proton.amqp.messaging.Outcome) Delivery(org.apache.qpid.proton.engine.Delivery) AsyncResult(org.apache.activemq.transport.amqp.client.util.AsyncResult)

Aggregations

Modified (org.apache.qpid.proton.amqp.messaging.Modified)7 IOException (java.io.IOException)2 InvalidDestinationException (javax.jms.InvalidDestinationException)2 Accepted (org.apache.qpid.proton.amqp.messaging.Accepted)2 Outcome (org.apache.qpid.proton.amqp.messaging.Outcome)2 Rejected (org.apache.qpid.proton.amqp.messaging.Rejected)2 Released (org.apache.qpid.proton.amqp.messaging.Released)2 TransactionalState (org.apache.qpid.proton.amqp.transaction.TransactionalState)2 DeliveryState (org.apache.qpid.proton.amqp.transport.DeliveryState)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ActiveMQQueueExistsException (org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException)1 ActiveMQSecurityException (org.apache.activemq.artemis.api.core.ActiveMQSecurityException)1 Message (org.apache.activemq.artemis.api.core.Message)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 IOCallback (org.apache.activemq.artemis.core.io.IOCallback)1 OperationContext (org.apache.activemq.artemis.core.persistence.OperationContext)1 MessageReference (org.apache.activemq.artemis.core.server.MessageReference)1 AMQPMessage (org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage)1 ActiveMQAMQPException (org.apache.activemq.artemis.protocol.amqp.exceptions.ActiveMQAMQPException)1