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


Java Delivery.getRemoteState方法代码示例

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


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

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

示例2: onDelivery

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
@Override
public void onDelivery(Event event) {
  final String methodName = "onDelivery";
  logger.entry(this, methodName, event);

  EngineConnection engineConnection = (EngineConnection)event.getConnection().getContext();
  Delivery delivery = event.getDelivery();
  if (event.getLink() instanceof Sender) {
      SendRequest sr = engineConnection.inProgressOutboundDeliveries.remove(delivery);
      Exception exception = null;
      if (delivery.getRemoteState() instanceof Rejected) {
          final Rejected rejected = (Rejected) delivery.getRemoteState();
          final ErrorCondition error = rejected.getError();
          if (error == null || error.getDescription() == null) {
              exception = new Exception("Message was rejected");
          } else {
              exception = new Exception(error.getDescription());
          }
      } else if (delivery.getRemoteState() instanceof Released) {
          exception = new Exception("Message was released");
      } else if (delivery.getRemoteState() instanceof Modified) {
          exception = new Exception("Message was modified");
      }
      if (!sr.retainLink) {
          event.getLink().close();
          event.getLink().free();
      }
      sr.getSender().tell(new SendResponse(sr, exception), this);
  } else if (delivery.isReadable() && !delivery.isPartial()) {    // Assuming link instanceof Receiver...
      Receiver receiver = (Receiver)event.getLink();
      int amount = delivery.pending();
      byte[] data = new byte[amount];
      receiver.recv(data, 0, amount);
      receiver.advance();

      EngineConnection.SubscriptionData subData = engineConnection.subscriptionData.get(event.getLink().getName());
      subData.unsettled++;
      QOS qos = delivery.remotelySettled() ? QOS.AT_MOST_ONCE : QOS.AT_LEAST_ONCE;
      subData.subscriber.tell(new DeliveryRequest(data, qos, event.getLink().getName(), delivery, event.getConnection()), this);
  }

  logger.exit(this, methodName);
}
 
开发者ID:mqlight,项目名称:java-mqlight,代码行数:44,代码来源:Engine.java

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

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


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