本文整理汇总了Java中org.apache.qpid.proton.engine.Receiver.open方法的典型用法代码示例。如果您正苦于以下问题:Java Receiver.open方法的具体用法?Java Receiver.open怎么用?Java Receiver.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.qpid.proton.engine.Receiver
的用法示例。
在下文中一共展示了Receiver.open方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
}
示例2: 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();
}
}
示例3: createInboundLink
import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
@Override
public IncomingLink createInboundLink(String address, ReliabilityMode mode, CreditMode creditMode)
throws MessagingException {
checkClosed();
String name = UUID.randomUUID().toString();
Receiver receiver = _ssn.receiver(name);
Source source = new Source();
// Target target = new Target();
if (address == null || address.isEmpty() || address.equals("#")) {
source.setDynamic(true);
} else {
source.setAddress(address);
}
receiver.setSource(source);
// receiver.setTarget(target);
switch (mode) {
case UNRELIABLE:
receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
receiver.setSenderSettleMode(SenderSettleMode.SETTLED);
break;
case AT_LEAST_ONCE:
receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
break;
// case EXACTLY_ONCE:
// receiver.setReceiverSettleMode(ReceiverSettleMode.SECOND);
// receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
// break;
}
receiver.open();
IncomingLinkImpl inLink = new IncomingLinkImpl(this, address, receiver, mode, creditMode);
inLink.setDynamicAddress(source.getDynamic());
_links.put(receiver, inLink);
receiver.setContext(inLink);
return inLink;
}
示例4: 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());
}
示例5: testNoReceiverFlowAfterDetachSentWhileDraining
import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的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);
}
示例6: 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());
}
示例7: createInboundLink
import org.apache.qpid.proton.engine.Receiver; //导入方法依赖的package包/类
@Override
public InboundLink createInboundLink(String address, InboundLinkMode mode, CreditMode creditMode)
throws NetworkException, MessagingException
{
Receiver receiver;
Source source = new Source();
Target target = new Target();
if (address == null || address.isEmpty() || address.equals("#"))
{
String temp = UUID.randomUUID().toString();
receiver = _ssn.receiver(temp);
source.setDynamic(true);
}
else
{
receiver = _ssn.receiver(address);
source.setAddress(address);
}
receiver.setSource(source);
receiver.setTarget(target);
switch (mode)
{
case AT_MOST_ONCE:
receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
receiver.setSenderSettleMode(SenderSettleMode.SETTLED);
break;
case AT_LEAST_ONCE:
receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
break;
case EXACTLY_ONCE:
receiver.setReceiverSettleMode(ReceiverSettleMode.SECOND);
receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
break;
}
receiver.open();
InboundLinkImpl inLink = new InboundLinkImpl(this, address, receiver, creditMode);
inLink.setDynamicAddress(source.getDynamic());
_links.put(receiver, inLink);
receiver.setContext(inLink);
_conn.write();
return inLink;
}