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


Java Receiver类代码示例

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


Receiver类属于org.apache.qpid.proton.engine包,在下文中一共展示了Receiver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDelivery

import org.apache.qpid.proton.engine.Receiver; //导入依赖的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.Receiver; //导入依赖的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: Pool

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
public Pool(Collector collector, final Router router) {
    this.collector = collector;
    connections = new HashMap<String,Connection>();

    if (router != null) {
        outgoingResolver = new LinkResolver<Sender>() {
            public Sender resolve(String address) {
                return router.getOutgoing(address).choose();
            }
        };
        incomingResolver = new LinkResolver<Receiver>() {
            public Receiver resolve(String address) {
                return router.getIncoming(address).choose();
            }
        };
    } else {
        outgoingResolver = new LinkResolver<Sender>() {
            public Sender resolve(String address) { return null; }
        };
        incomingResolver = new LinkResolver<Receiver>() {
            public Receiver resolve(String address) { return null; }
        };
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:25,代码来源:Pool.java

示例4: onUnhandled

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void onUnhandled(Event event) {
    int window = this.window;
    Link link = event.getLink();

    switch(event.getType()) {
    case LINK_LOCAL_OPEN:
    case LINK_REMOTE_OPEN:
    case LINK_FLOW:
    case DELIVERY:
        if (link instanceof Receiver) {
            this.drained += link.drained();
            if (this.drained == 0) {
                topup((Receiver)link, window);
            }
        }
        break;
    default:
        break;
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:22,代码来源:FlowController.java

示例5: onLinkRemoteOpen

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void onLinkRemoteOpen(Event e) {
    System.out.println("onLinkRemoteOpen");
    e.getLink().open();
    if (e.getLink() instanceof Sender) {
        Sender sender = (Sender)e.getLink();
        delivery = sender.delivery(new byte[]{1});
        sender.send(new byte[]{1, 2, 3}, 0, 3);
        sender.advance();
    } else {
        Receiver receiver = (Receiver)e.getLink();
        receiver.flow(1024);
    }
    if (closeConnection) {
        e.getConnection().setCondition(new ErrorCondition(Symbol.getSymbol("symbol"), "Something went wrong!"));
        e.getConnection().close();
    }
}
 
开发者ID:mqlight,项目名称:java-mqlight,代码行数:19,代码来源:TestEngine.java

示例6: processFlowUpdates

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void processFlowUpdates(AmqpConnection connection) throws IOException {
   if (pullRequest != null || stopRequest != null) {
      Receiver receiver = getEndpoint();
      if (receiver.getRemoteCredit() <= 0 && receiver.getQueued() == 0) {
         if (pullRequest != null) {
            pullRequest.onSuccess();
            pullRequest = null;
         }

         if (stopRequest != null) {
            stopRequest.onSuccess();
            stopRequest = null;
         }
      }
   }

   LOG.trace("Consumer {} flow updated, remote credit = {}", getSubscriptionName(), getEndpoint().getRemoteCredit());

   super.processFlowUpdates(connection);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:AmqpReceiver.java

示例7: remoteLinkOpened

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
protected void remoteLinkOpened(Link link) throws Exception {

      AMQPSessionContext protonSession = getSessionExtension(link.getSession());

      link.setSource(link.getRemoteSource());
      link.setTarget(link.getRemoteTarget());
      if (link instanceof Receiver) {
         Receiver receiver = (Receiver) link;
         if (link.getRemoteTarget() instanceof Coordinator) {
            Coordinator coordinator = (Coordinator) link.getRemoteTarget();
            protonSession.addTransactionHandler(coordinator, receiver);
         } else {
            protonSession.addReceiver(receiver);
         }
      } else {
         Sender sender = (Sender) link;
         protonSession.addSender(sender);
      }
   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:20,代码来源:AMQPConnectionContext.java

示例8: addReceiver

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
public void addReceiver(Receiver receiver) throws Exception {
   try {
      ProtonServerReceiverContext protonReceiver = new ProtonServerReceiverContext(sessionSPI, connection, this, receiver);
      protonReceiver.initialise();
      receivers.put(receiver, protonReceiver);
      ServerProducer serverProducer = new ServerProducerImpl(receiver.getName(), "AMQP", receiver.getTarget().getAddress());
      sessionSPI.addProducer(serverProducer);
      receiver.setContext(protonReceiver);
      connection.lock();
      try {
         receiver.open();
      } finally {
         connection.unlock();
      }
   } catch (ActiveMQAMQPException e) {
      receivers.remove(receiver);
      receiver.setTarget(null);
      receiver.setCondition(new ErrorCondition(e.getAmqpError(), e.getMessage()));
      connection.lock();
      try {
         receiver.close();
      } finally {
         connection.unlock();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:27,代码来源:AMQPSessionContext.java

示例9: add

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
private void add(Receiver rcv) {
    String address = getAddress(rcv);
    Routes<Receiver> routes = incoming.get(address);
    if (routes == null) {
        routes = new Routes<Receiver>();
        incoming.put(address, routes);
    }
    routes.add(rcv);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:10,代码来源:Router.java

示例10: remove

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
private void remove(Receiver rcv) {
    String address = getAddress(rcv);
    Routes<Receiver> routes = incoming.get(address);
    if (routes != null) {
        routes.remove(rcv);
        if (routes.size() == 0) {
            incoming.remove(address);
        }
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:11,代码来源:Router.java

示例11: onLinkLocalOpen

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void onLinkLocalOpen(Event evt) {
    Link link = evt.getLink();
    if (link instanceof Receiver) {
        Receiver receiver = (Receiver) link;

        if (block) {
            receiver.flow(count);
        } else {
            receiver.drain(count);
        }
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:14,代码来源:Drain.java

示例12: onLinkFlow

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void onLinkFlow(Event evt) {
    Link link = evt.getLink();
    if (link instanceof Receiver) {
        Receiver receiver = (Receiver) link;

        if (!receiver.draining()) {
            receiver.getSession().getConnection().close();
        }
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:12,代码来源:Drain.java

示例13: onLinkLocalOpen

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void onLinkLocalOpen(Event evt) {
    Link link = evt.getLink();
    if (link instanceof Receiver) {
        topUp((Receiver) link);
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:8,代码来源:FlowController.java

示例14: onLinkRemoteOpen

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void onLinkRemoteOpen(Event evt) {
    Link link = evt.getLink();
    if (link instanceof Receiver) {
        topUp((Receiver) link);
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:8,代码来源:FlowController.java

示例15: onLinkFlow

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void onLinkFlow(Event evt) {
    Link link = evt.getLink();
    if (link instanceof Receiver) {
        topUp((Receiver) link);
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:8,代码来源:FlowController.java


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