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


Java Receiver.flow方法代码示例

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


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

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

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

示例3: testReceiverFlowBeforeOpenConnection

import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
@Test
public void testReceiverFlowBeforeOpenConnection()
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

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

    Receiver reciever = session.receiver("myReceiver");
    reciever.flow(5);

    pumpMockTransport(transport);

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

    // Now open the connection, expect the Open and Begin frames but
    // nothing else as we haven't opened the receiver itself yet.
    connection.open();

    pumpMockTransport(transport);

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

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:29,代码来源:TransportImplTest.java

示例4: offerProducerCredit

import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
public void offerProducerCredit(final SimpleString address,
                                final int credits,
                                final int threshold,
                                final Receiver receiver) {
   try {
      if (address == null) {
         connection.lock();
         try {
            receiver.flow(credits);
         } finally {
            connection.unlock();
         }
         connection.flush();
         return;
      }
      final PagingStore store = manager.getServer().getPagingManager().getPageStore(address);
      store.checkMemory(new Runnable() {
         @Override
         public void run() {
            connection.lock();
            try {
               if (receiver.getRemoteCredit() <= threshold) {
                  receiver.flow(credits);
               }
            } finally {
               connection.unlock();
            }
            connection.flush();
         }
      });
   } catch (Exception e) {
      throw new RuntimeException(e);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:35,代码来源:AMQPSessionCallback.java

示例5: addTransactionHandler

import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
public void addTransactionHandler(Coordinator coordinator, Receiver receiver) {
   ProtonTransactionHandler transactionHandler = new ProtonTransactionHandler(sessionSPI, connection);

   coordinator.setCapabilities(Symbol.getSymbol("amqp:local-transactions"), Symbol.getSymbol("amqp:multi-txns-per-ssn"), Symbol.getSymbol("amqp:multi-ssns-per-txn"));

   receiver.setContext(transactionHandler);
   connection.lock();
   try {
      receiver.open();
      receiver.flow(connection.getAmqpCredits());
   } finally {
      connection.unlock();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:15,代码来源:AMQPSessionContext.java

示例6: issueCredits

import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
void issueCredits(int credits, boolean drain) {
  Receiver receiver = (Receiver) _link;
  if (drain) {
    // receiver.setDrain(true);
  }
  receiver.flow(credits);
  /*print("\n==============================");
  print("\nSetting credits=%s, for link '%s'", credits, this.getName());
  print("\n==============================");*/
  _ssn.getConnection().write();
}
 
开发者ID:vert-x3,项目名称:vertx-amqp-service,代码行数:12,代码来源:IncomingLinkImpl.java

示例7: issueCredits

import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
void issueCredits(int credits, boolean drain) throws NetworkException
{
    Receiver receiver = (Receiver) _link;
    if (drain)
    {
        //receiver.setDrain(true);
    }
    receiver.flow(credits);
    _ssn.getConnection().write();
}
 
开发者ID:rajith77,项目名称:splash,代码行数:11,代码来源:InboundLinkImpl.java

示例8: topUp

import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
private void topUp(Receiver rcv) {
    int delta = window - rcv.getCredit();
    rcv.flow(delta);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:5,代码来源:FlowController.java

示例9: topup

import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
private void topup(Receiver link, int window) {
    int delta = window - link.getCredit();
    link.flow(delta);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:5,代码来源:FlowController.java

示例10: testReceiverFlowAfterCloseSent

import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
/**
 * Verify that no Flow frame is emitted by the Transport should a Receiver
 * have credit added after the Close frame was sent.
 */
@Test
public void testReceiverFlowAfterCloseSent()
{
    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.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, 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);

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

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    transport.handleFrame(new TransportFrame(0, begin, null));

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

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

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

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

    // Grant new credit for the Receiver and verify the transport doesn't
    // send any Flow frame, as a Close frame was sent already.
    receiver.flow(1);
    pumpMockTransport(transport);

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

示例11: testDispositionAfterCloseSent

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


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