本文整理汇总了Java中org.apache.qpid.proton.engine.Session.receiver方法的典型用法代码示例。如果您正苦于以下问题:Java Session.receiver方法的具体用法?Java Session.receiver怎么用?Java Session.receiver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.qpid.proton.engine.Session
的用法示例。
在下文中一共展示了Session.receiver方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newIncoming
import org.apache.qpid.proton.engine.Session; //导入方法依赖的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;
}
示例2: doOpenLinkBeforeOpenConnectionTestImpl
import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
void doOpenLinkBeforeOpenConnectionTestImpl(boolean receiverLink)
{
MockTransportImpl transport = new MockTransportImpl();
Connection connection = Proton.connection();
transport.bind(connection);
Session session = connection.session();
session.open();
Link link = null;
if(receiverLink)
{
link = session.receiver("myReceiver");
}
else
{
link = session.sender("mySender");
}
link.open();
pumpMockTransport(transport);
assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 0, transport.writes.size());
// Now open the connection, expect the Open, Begin, and Attach frames
connection.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);
}
示例3: testReceiverFlowBeforeOpenConnection
import org.apache.qpid.proton.engine.Session; //导入方法依赖的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: testGetTransportWithLinkContext
import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
@Test
public void testGetTransportWithLinkContext()
{
Transport transport = Transport.Factory.create();
Connection connection = Connection.Factory.create();
transport.bind(connection);
Session session = connection.session();
Link link = session.receiver("myReceiver");
EventImpl event = createEvent(link, Event.Type.LINK_INIT);
assertNotNull("No transport returned", event.getTransport());
assertSame("Incorrect transport returned", transport, event.getTransport());
}
示例5: doOpenLinkBeforeOpenSessionTestImpl
import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
void doOpenLinkBeforeOpenSessionTestImpl(boolean receiverLink)
{
MockTransportImpl transport = new MockTransportImpl();
Connection connection = Proton.connection();
transport.bind(connection);
// Open the connection
connection.open();
// Create but don't open the session
Session session = connection.session();
// Open the link
Link link = null;
if(receiverLink)
{
link = session.receiver("myReceiver");
}
else
{
link = session.sender("mySender");
}
link.open();
pumpMockTransport(transport);
// Expect only an Open frame, no attach should be sent as the session isn't open
assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 1, transport.writes.size());
assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
// Now open the session, expect the Begin
session.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);
// Note: an Attach wasn't sent because link is no longer 'modified' after earlier pump. It
// could easily be argued it should, given how the engine generally handles things. Seems
// unlikely to be of much real world concern.
//assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
}
示例6: doLinkAttachAfterEndSentTestImpl
import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
void doLinkAttachAfterEndSentTestImpl(boolean receiverLink)
{
MockTransportImpl transport = new MockTransportImpl();
Connection connection = Proton.connection();
transport.bind(connection);
connection.open();
Session session = connection.session();
session.open();
Link link = null;
if(receiverLink)
{
link = session.receiver("myReceiver");
}
else
{
link = session.sender("mySender");
}
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);
// Send the necessary responses to open/begin
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));
assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
// Cause a End frame to be sent
session.close();
pumpMockTransport(transport);
assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
assertTrue("Unexpected frame type", transport.writes.get(2) instanceof End);
// Open the link and verify the transport doesn't
// send any Attach frame, as an End frame was sent already.
link.open();
pumpMockTransport(transport);
assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
}
示例7: doLinkDetachAfterEndSentTestImpl
import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
void doLinkDetachAfterEndSentTestImpl(boolean receiverLink)
{
MockTransportImpl transport = new MockTransportImpl();
Connection connection = Proton.connection();
transport.bind(connection);
connection.open();
Session session = connection.session();
session.open();
Link link = null;
if(receiverLink)
{
link = session.receiver("myReceiver");
}
else
{
link = session.sender("mySender");
}
link.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
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));
assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
// Cause an End frame to be sent
session.close();
pumpMockTransport(transport);
assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
assertTrue("Unexpected frame type", transport.writes.get(3) instanceof End);
// Close the link and verify the transport doesn't
// send any Detach frame, as an End frame was sent already.
link.close();
pumpMockTransport(transport);
assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
}
示例8: doLinkAttachAfterCloseSentTestImpl
import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
void doLinkAttachAfterCloseSentTestImpl(boolean receiverLink)
{
MockTransportImpl transport = new MockTransportImpl();
Connection connection = Proton.connection();
transport.bind(connection);
connection.open();
Session session = connection.session();
session.open();
Link link = null;
if(receiverLink)
{
link = session.receiver("myReceiver");
}
else
{
link = session.sender("mySender");
}
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);
// Send the necessary responses to open/begin
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));
assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
// Cause a Close frame to be sent
connection.close();
pumpMockTransport(transport);
assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Close);
// Open the link and verify the transport doesn't
// send any Attach frame, as a Close frame was sent already.
link.open();
pumpMockTransport(transport);
assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
}
示例9: testReceiverFlowAfterCloseSent
import org.apache.qpid.proton.engine.Session; //导入方法依赖的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());
}
示例10: testNoReceiverFlowAfterDetachSentWhileDraining
import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
/**
* Verify that no Flow frame is emitted by the Transport should a Receiver
* have pending drain when a detach is sent for that receiver.
*/
@Test
public void testNoReceiverFlowAfterDetachSentWhileDraining()
{
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());
// Start a drain for the Receiver and verify the transport doesn't
// send any Flow frame, due to the detach being initiated.
receiver.drain(10);
pumpMockTransport(transport);
// Cause the Detach frame to be sent
receiver.detach();
pumpMockTransport(transport);
assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 5, transport.writes.size());
assertTrue("Unexpected frame type", transport.writes.get(4) instanceof Detach);
}
示例11: testDispositionAfterCloseSent
import org.apache.qpid.proton.engine.Session; //导入方法依赖的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());
}