• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Receiver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: onDelivery

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


示例17: newIncoming

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
public Receiver newIncoming(Session ssn, String remote, String local) {
    Receiver rcv = ssn.receiver(String.format("%s-%s", remote, local));
    Source src = new Source();
    src.setAddress(remote);
    rcv.setSource(src);
    Target tgt = new Target();
    tgt.setAddress(remote);
    rcv.setTarget(tgt);
    return rcv;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:11,代码来源:Pool.java


示例18: onDelivery

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void onDelivery(Event event) {
    Receiver recv = (Receiver)event.getLink();
    Delivery delivery = recv.current();
    if (delivery.isReadable() && !delivery.isPartial()) {
        int size = delivery.pending();
        byte[] buffer = new byte[size];
        int read = recv.recv(buffer, 0, buffer.length);
        recv.advance();

        Message msg = Proton.message();
        msg.decode(buffer, 0, read);
        System.out.println(((AmqpValue)msg.getBody()).getValue());
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:16,代码来源:Recv.java


示例19: getReceiver

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public Receiver getReceiver()
{
    if (context instanceof Receiver) {
        return (Receiver) context;
    } else {
        Link link = getLink();
        if (link instanceof Receiver) {
            return (Receiver) link;
        }
        return null;
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:14,代码来源:EventImpl.java


示例20: receiveMessageFromServer

import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
private Delivery receiveMessageFromServer(String deliveryTag, int count)
{
    Delivery delivery = getClient().getConnection().getWorkHead();
    Receiver clientReceiver = getClient().getReceiver();

    assertTrue(Arrays.equals(deliveryTag.getBytes(StandardCharsets.UTF_8), delivery.getTag()));
    assertEquals("The received delivery should be on our receiver",
            clientReceiver, delivery.getLink());

    assertNull(delivery.getLocalState());
    assertNull(delivery.getRemoteState());

    assertFalse(delivery.isPartial());
    assertTrue(delivery.isReadable());

    int size = delivery.available();
    byte[] received = new byte[size];

    int len = clientReceiver.recv(received, 0, size);

    assertEquals("Should have received " + size + " bytes", size, len);
    assertEquals("Should be no bytes left", 0, delivery.available());

    Message m = Proton.message();
    m.decode(received, 0, len);

    Object messageBody = ((AmqpValue)m.getBody()).getValue();
    assertEquals("Unexpected message content", count, messageBody);

    boolean receiverAdvanced = clientReceiver.advance();
    assertTrue("receiver has not advanced", receiverAdvanced);

    delivery.setContext(count);

    return delivery;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:37,代码来源:DeferredSettlementTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InvalidInputException类代码示例发布时间:2022-05-22
下一篇:
Java Factory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap