当前位置: 首页>>代码示例>>Java>>正文


Java Delivery.getContext方法代码示例

本文整理汇总了Java中org.apache.qpid.proton.engine.Delivery.getContext方法的典型用法代码示例。如果您正苦于以下问题:Java Delivery.getContext方法的具体用法?Java Delivery.getContext怎么用?Java Delivery.getContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.qpid.proton.engine.Delivery的用法示例。


在下文中一共展示了Delivery.getContext方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: releasePrefetch

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
private void releasePrefetch() {
    Delivery delivery = getEndpoint().head();

    while (delivery != null) {
        Delivery current = delivery;
        delivery = delivery.next();

        if (!(current.getContext() instanceof JmsInboundMessageDispatch)) {
            LOG.debug("{} Found incomplete delivery with no context during release processing", AmqpConsumer.this);
            continue;
        }

        JmsInboundMessageDispatch envelope = (JmsInboundMessageDispatch) current.getContext();
        if (!envelope.isDelivered()) {
            current.disposition(Released.getInstance());
            current.settle();
        }
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:20,代码来源:AmqpConsumer.java

示例2: closeResource

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
@Override
public void closeResource(AmqpProvider provider, Throwable cause, boolean localClose) {

    // Alert any pending operation that the link failed to complete the pending
    // begin / commit / rollback operation.
    Delivery pending = getEndpoint().head();
    while (pending != null) {
        Delivery nextPending = pending.next();
        if (pending.getContext() != null && pending.getContext() instanceof OperationContext) {
            OperationContext context = (OperationContext) pending.getContext();
            context.request.onFailure(cause);
        }

        pending = nextPending;
    }

    // Override the base class version because we do not want to propagate
    // an error up to the client if remote close happens as that is an
    // acceptable way for the remote to indicate the discharge could not
    // be applied.

    if (getParent() != null) {
        getParent().removeChildResource(this);
    }

    if (getEndpoint() != null) {
        getEndpoint().close();
        getEndpoint().free();
    }

    LOG.debug("Transaction Coordinator link {} was remotely closed", getResourceInfo());
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:33,代码来源:AmqpTransactionCoordinator.java

示例3: recover

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
/**
 * Recovers all previously delivered but not acknowledged messages.
 *
 * @throws Exception if an error occurs while performing the recover.
 */
public void recover() throws Exception {
    LOG.debug("Session Recover for consumer: {}", getResourceInfo().getId());

    ArrayList<JmsInboundMessageDispatch> redispatchList = new ArrayList<JmsInboundMessageDispatch>();

    Delivery delivery = getEndpoint().head();
    while (delivery != null) {
        Delivery current = delivery;
        delivery = delivery.next();

        if (!(current.getContext() instanceof JmsInboundMessageDispatch)) {
            LOG.debug("{} Found incomplete delivery with no context during recover processing", AmqpConsumer.this);
            continue;
        }

        JmsInboundMessageDispatch envelope = (JmsInboundMessageDispatch) current.getContext();
        if (envelope.isDelivered()) {
            envelope.getMessage().getFacade().setRedeliveryCount(
                envelope.getMessage().getFacade().getRedeliveryCount() + 1);
            envelope.setEnqueueFirst(true);
            envelope.setDelivered(false);

            redispatchList.add(envelope);
        }
    }

    ListIterator<JmsInboundMessageDispatch> reverseIterator = redispatchList.listIterator(redispatchList.size());
    while (reverseIterator.hasPrevious()) {
        deliver(reverseIterator.previous());
    }
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:37,代码来源:AmqpConsumer.java

示例4: processDeliveryUpdates

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
@Override
public void processDeliveryUpdates() {
    List<Delivery> toRemove = new ArrayList<Delivery>();

    for (Delivery delivery : pending) {
        DeliveryState state = delivery.getRemoteState();
        if (state == null) {
            continue;
        }

        @SuppressWarnings("unchecked")
        AsyncResult<Void> request = (AsyncResult<Void>) delivery.getContext();

        if (state instanceof Accepted) {
            toRemove.add(delivery);
            LOG.trace("State of delivery accepted: {}", delivery);
            tagGenerator.returnTag(delivery.getTag());
            if (request != null && !request.isComplete()) {
                request.onSuccess();
            }
        } else if (state instanceof Rejected) {
            Exception remoteError = getRemoteError();
            toRemove.add(delivery);
            tagGenerator.returnTag(delivery.getTag());
            if (request != null && !request.isComplete()) {
                request.onFailure(remoteError);
            } else {
                connection.getProvider().fireProviderException(remoteError);
            }
        } else if (state instanceof TransactionalState) {
            LOG.info("State of delivery is Transacted: {}", state);
        } else {
            LOG.warn("Message send updated with unsupported state: {}", state);
        }
    }

    pending.removeAll(toRemove);
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:39,代码来源:AmqpFixedProducer.java

示例5: recover

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
/**
 * Recovers all previously delivered but not acknowledged messages.
 */
public void recover() {
    LOG.debug("Session Recover for consumer: {}", info.getConsumerId());
    for (Delivery delivery : delivered.values()) {
        // TODO - increment redelivery counter and apply connection redelivery policy
        //        to those messages that are past max redlivery.
        JmsInboundMessageDispatch envelope = (JmsInboundMessageDispatch) delivery.getContext();
        envelope.onMessageRedelivered();
        deliver(envelope);
    }
    delivered.clear();
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:15,代码来源:AmqpConsumer.java

示例6: postRollback

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
/**
 * Redeliver Acknowledge all previously delivered messages and clear state to prepare for
 * the next TX to start.
 */
public void postRollback() {
    for (Delivery delivery : delivered.values()) {
        JmsInboundMessageDispatch envelope = (JmsInboundMessageDispatch) delivery.getContext();
        acknowledge(envelope, ACK_TYPE.REDELIVERED);
    }
    this.delivered.clear();
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:12,代码来源:AmqpConsumer.java

示例7: settle

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
private void settle(final Delivery delivery, final int ackType) throws Exception {
    byte[] tag = delivery.getTag();
    if (tag != null && tag.length > 0 && delivery.remotelySettled()) {
        checkinTag(tag);
    }

    if (ackType == -1) {
        // we are going to settle, but redeliver.. we we won't yet ack to ActiveMQ
        delivery.settle();
        onMessageDispatch((MessageDispatch) delivery.getContext());
    } else {
        MessageDispatch md = (MessageDispatch) delivery.getContext();
        MessageAck ack = new MessageAck();
        ack.setConsumerId(consumerId);
        ack.setFirstMessageId(md.getMessage().getMessageId());
        ack.setLastMessageId(md.getMessage().getMessageId());
        ack.setMessageCount(1);
        ack.setAckType((byte) ackType);
        ack.setDestination(md.getDestination());

        DeliveryState remoteState = delivery.getRemoteState();
        if (remoteState != null && remoteState instanceof TransactionalState) {
            TransactionalState s = (TransactionalState) remoteState;
            long txid = toLong(s.getTxnId());
            LocalTransactionId localTxId = new LocalTransactionId(connectionId, txid);
            ack.setTransactionId(localTxId);

            // Store the message sent in this TX we might need to re-send on rollback
            md.getMessage().setTransactionId(localTxId);
            dispatchedInTx.addFirst(md);
        }

        LOG.trace("Sending Ack to ActiveMQ: {}", ack);

        sendToActiveMQ(ack, new ResponseHandler() {
            @Override
            public void onResponse(IAmqpProtocolConverter converter, Response response) throws IOException {
                if (response.isException()) {
                    if (response.isException()) {
                        Throwable exception = ((ExceptionResponse) response).getException();
                        exception.printStackTrace();
                        sender.close();
                    }
                } else {
                    delivery.settle();
                }
                pumpProtonToSocket();
            }
        });
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:52,代码来源:AmqpProtocolConverter.java

示例8: acknowledge

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
/**
 * Called to acknowledge all messages that have been marked as delivered but
 * have not yet been marked consumed.  Usually this is called as part of an
 * client acknowledge session operation.
 *
 * Only messages that have already been acknowledged as delivered by the JMS
 * framework will be in the delivered Map.  This means that the link credit
 * would already have been given for these so we just need to settle them.
 *
 * @param ackType the type of acknowledgement to perform
 */
public void acknowledge(ACK_TYPE ackType) {
    LOG.trace("Session Acknowledge for consumer {} with ack type {}", getResourceInfo().getId(), ackType);
    Delivery delivery = getEndpoint().head();
    while (delivery != null) {
        Delivery current = delivery;
        delivery = delivery.next();

        if (!(current.getContext() instanceof JmsInboundMessageDispatch)) {
            LOG.debug("{} Found incomplete delivery with no context during recover processing", AmqpConsumer.this);
            continue;
        }

        JmsInboundMessageDispatch envelope = (JmsInboundMessageDispatch) current.getContext();
        if (envelope.isDelivered()) {
            switch (ackType) {
                case ACCEPTED:
                    current.disposition(Accepted.getInstance());
                    break;
                case RELEASED:
                    current.disposition(Released.getInstance());
                    break;
                case REJECTED:
                    current.disposition(REJECTED);
                    break;
                case MODIFIED_FAILED:
                    current.disposition(MODIFIED_FAILED);
                    break;
                case MODIFIED_FAILED_UNDELIVERABLE:
                    current.disposition(MODIFIED_FAILED_UNDELIVERABLE);
                    break;
                default:
                    throw new IllegalArgumentException("Invalid acknowledgement type specified: " + ackType);
            }

            current.settle();
            deliveredCount--;
        }
    }

    tryCompleteDeferredClose();
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:53,代码来源:AmqpConsumer.java


注:本文中的org.apache.qpid.proton.engine.Delivery.getContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。