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


Java Delivery.getLink方法代码示例

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


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

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

示例3: getLink

import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
@Override
public Link getLink()
{
    if (context instanceof Link) {
        return (Link) context;
    } else {
        Delivery dlv = getDelivery();
        if (dlv == null) {
            return null;
        }
        return dlv.getLink();
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:14,代码来源:EventImpl.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.getLink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。