本文整理汇总了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();
}
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例8: topUp
import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
private void topUp(Receiver rcv) {
int delta = window - rcv.getCredit();
rcv.flow(delta);
}
示例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);
}
示例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());
}
示例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());
}