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


Java Delivery.disposition方法代码示例

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


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

示例1: onDelivery

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
@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);
        }
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:24,代码来源:Server.java

示例2: rollbackRedelivery

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
@Override
public void rollbackRedelivery(Transaction txn, MessageReference ref, long timeBase, Map<QueueImpl, LinkedList<MessageReference>> queueMap) throws Exception {
   ProtonTransactionImpl tx = (ProtonTransactionImpl) txn;

   if (tx.getDeliveries().containsKey(ref)) {
      Delivery del = tx.getDeliveries().get(ref).getA();
      ServerConsumer consumer = (ServerConsumer) tx.getDeliveries().get(ref).getB().getBrokerConsumer();
      // Rollback normally if the delivery is not settled or a forced TX rollback is done (e.g. connection drop).
      if (del.remotelySettled() || !tx.isDischarged()) {
         super.rollbackRedelivery(tx, ref, timeBase, queueMap);
      } else {
         ref.incrementDeliveryCount();
         consumer.backToDelivering(ref);
         del.disposition(del.getLocalState() == null ? del.getDefaultDeliveryState() : del.getLocalState());
      }
   } else {
      super.rollbackRedelivery(tx, ref, timeBase, queueMap);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:20,代码来源:ProtonTransactionRefsOperation.java

示例3: disposition

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
void disposition(long sequence, DeliveryState state, int... flags) {
  int flag = flags.length == 1 ? flags[0] : 0;
  boolean cumilative = (flag & CUMULATIVE) != 0;
  boolean settle = (flag & SETTLE) != 0;

  long count = cumilative ? _lastDispositionMark.get() : sequence;
  long end = sequence;

  while (count <= end) {
    Delivery d = _unsettled.get(count);
    if (d != null) {
      d.disposition(state);
    }
    count++;
  }
  _lastDispositionMark.set(end);
  if (settle) {
    settle(sequence, cumilative, false);
  }
  _conn.write();
}
 
开发者ID:vert-x3,项目名称:vertx-amqp-service,代码行数:22,代码来源:SessionImpl.java

示例4: disposition

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
void disposition(InboundMessage msg, DeliveryState state, int... flags) throws NetworkException
{
    int flag = flags.length == 1 ? flags[0] : 0;
    boolean cumilative = (flag & CUMULATIVE) != 0;
    boolean settle = (flag & SETTLE) != 0;

    long count = cumilative ? _lastDispositionMark.get() : msg.getSequence();
    long end = msg.getSequence();

    while (count <= end)
    {
        Delivery d = _unsettled.get(count);
        if (d != null)
        {
            d.disposition(state);
        }
        count++;
    }
    _lastDispositionMark.set(end);
    if (settle)
    {
        settle(msg, cumilative, false);
    }
    _conn.write();
}
 
开发者ID:rajith77,项目名称:splash,代码行数:26,代码来源:SessionImpl.java

示例5: 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

示例6: deliveryFailed

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
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);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:11,代码来源:AmqpReceiver.java

示例7: doSend

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
private void doSend(AmqpMessage message, AsyncResult request, AmqpTransactionId txId) throws Exception {
   LOG.trace("Producer sending message: {}", message);

   Delivery delivery = null;
   if (presettle) {
      delivery = getEndpoint().delivery(EMPTY_BYTE_ARRAY, 0, 0);
   } else {
      byte[] tag = tagGenerator.getNextTag();
      delivery = getEndpoint().delivery(tag, 0, tag.length);
   }

   delivery.setContext(request);

   Binary amqpTxId = null;
   if (txId != null) {
      amqpTxId = txId.getRemoteTxId();
   } else if (session.isInTransaction()) {
      amqpTxId = session.getTransactionId().getRemoteTxId();
   }

   if (amqpTxId != null) {
      TransactionalState state = new TransactionalState();
      state.setTxnId(amqpTxId);
      delivery.disposition(state);
   }

   encodeAndSend(message.getWrappedMessage(), delivery);

   if (presettle) {
      delivery.settle();
      request.onSuccess();
   } else {
      pending.add(delivery);
      getEndpoint().advance();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:37,代码来源:AmqpSender.java

示例8: settleDelivery

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
protected void settleDelivery(Delivery incoming, DeliveryState state) {
    incoming.disposition(state);
    incoming.settle();
    // TODO: this flows credit, which we might not want, e.g if
    // a drain was issued to stop the link.
    sendFlowIfNeeded();
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:8,代码来源:AmqpConsumer.java

示例9: deliveryFailed

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
protected void deliveryFailed(Delivery incoming, boolean expandCredit) {
    Modified disposition = new Modified();
    disposition.setUndeliverableHere(true);
    disposition.setDeliveryFailed(true);
    incoming.disposition(disposition);
    incoming.settle();
    if (expandCredit) {
        endpoint.flow(1);
    }
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:11,代码来源:AmqpConsumer.java

示例10: testDispositionAfterCloseSent

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
/**
 * Verify that no Disposition frame is emitted by the Transport should a Delivery
 * have disposition applied after the Close frame was sent.
 */
@Test
public void testDispositionAfterCloseSent()
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    connection.open();

    Session session = connection.session();
    session.open();

    String linkName = "myReceiver";
    Receiver receiver = session.receiver(linkName);
    receiver.flow(5);
    receiver.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
    assertTrue("Unexpected frame type", transport.writes.get(3) instanceof Flow);

    Delivery delivery = receiver.current();
    assertNull("Should not yet have a delivery", delivery);

    // Send the necessary responses to open/begin/attach as well as a transfer
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    begin.setNextOutgoingId(UnsignedInteger.ONE);
    begin.setIncomingWindow(UnsignedInteger.valueOf(1024));
    begin.setOutgoingWindow(UnsignedInteger.valueOf(1024));
    transport.handleFrame(new TransportFrame(0, begin, null));

    Attach attach = new Attach();
    attach.setHandle(UnsignedInteger.ZERO);
    attach.setRole(Role.SENDER);
    attach.setName(linkName);
    attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
    transport.handleFrame(new TransportFrame(0, attach, null));

    String deliveryTag = "tag1";
    String messageContent = "content1";
    handleTransfer(transport, 1, deliveryTag, messageContent);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());

    delivery = verifyDelivery(receiver, deliveryTag, messageContent);
    assertNotNull("Should now have a delivery", delivery);

    // Cause the Close frame to be sent
    connection.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 5, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(4) instanceof Close);

    delivery.disposition(Released.getInstance());
    delivery.settle();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 5, transport.writes.size());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:74,代码来源:TransportImplTest.java

示例11: onMessage

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
@Override
public void onMessage(Delivery delivery) throws ActiveMQAMQPException {
   Receiver receiver;
   try {

      if (!delivery.isReadable()) {
         return;
      }
      if (delivery.isPartial()) {
         return;
      }

      receiver = ((Receiver) delivery.getLink());

      Transaction tx = null;
      byte[] data;

      data = new byte[delivery.available()];
      receiver.recv(data, 0, data.length);
      receiver.advance();

      if (delivery.getRemoteState() instanceof TransactionalState) {
         TransactionalState txState = (TransactionalState) delivery.getRemoteState();
         tx = this.sessionSPI.getTransaction(txState.getTxnId(), false);
      }

      sessionSPI.serverSend(this, tx, receiver, delivery, address, delivery.getMessageFormat(), data);

      flow(amqpCredits, minCreditRefresh);
   } catch (Exception e) {
      log.warn(e.getMessage(), e);
      Rejected rejected = new Rejected();
      ErrorCondition condition = new ErrorCondition();

      if (e instanceof ActiveMQSecurityException) {
         condition.setCondition(AmqpError.UNAUTHORIZED_ACCESS);
      } else {
         condition.setCondition(Symbol.valueOf("failed"));
      }

      condition.setDescription(e.getMessage());
      rejected.setError(condition);
      connection.lock();
      try {
         delivery.disposition(rejected);
         delivery.settle();
      } finally {
         connection.unlock();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:52,代码来源:ProtonServerReceiverContext.java

示例12: 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

示例13: 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.
 */
public void acknowledge() {
    LOG.trace("Session Acknowledge for consumer: {}", info.getConsumerId());
    for (Delivery delivery : delivered.values()) {
        delivery.disposition(Accepted.getInstance());
        delivery.settle();
    }
    delivered.clear();
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:18,代码来源:AmqpConsumer.java


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