本文整理汇总了Java中org.apache.qpid.proton.engine.Delivery.getLink方法的典型用法代码示例。如果您正苦于以下问题:Java Delivery.getLink方法的具体用法?Java Delivery.getLink怎么用?Java Delivery.getLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.qpid.proton.engine.Delivery
的用法示例。
在下文中一共展示了Delivery.getLink方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDelivery
import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的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);
}
}
}
示例2: onDelivery
import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的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();
}
}
}
示例3: getLink
import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
@Override
public Link getLink()
{
if (context instanceof Link) {
return (Link) context;
} else {
Delivery dlv = getDelivery();
if (dlv == null) {
return null;
}
return dlv.getLink();
}
}
示例4: onMessage
import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
@Override
public void onMessage(Delivery delivery) throws ActiveMQAMQPException {
Receiver receiver;
try {
if (!delivery.isReadable()) {
return;
}
if (delivery.isPartial()) {
return;
}
receiver = ((Receiver) delivery.getLink());
Transaction tx = null;
byte[] data;
data = new byte[delivery.available()];
receiver.recv(data, 0, data.length);
receiver.advance();
if (delivery.getRemoteState() instanceof TransactionalState) {
TransactionalState txState = (TransactionalState) delivery.getRemoteState();
tx = this.sessionSPI.getTransaction(txState.getTxnId(), false);
}
sessionSPI.serverSend(this, tx, receiver, delivery, address, delivery.getMessageFormat(), data);
flow(amqpCredits, minCreditRefresh);
} catch (Exception e) {
log.warn(e.getMessage(), e);
Rejected rejected = new Rejected();
ErrorCondition condition = new ErrorCondition();
if (e instanceof ActiveMQSecurityException) {
condition.setCondition(AmqpError.UNAUTHORIZED_ACCESS);
} else {
condition.setCondition(Symbol.valueOf("failed"));
}
condition.setDescription(e.getMessage());
rejected.setError(condition);
connection.lock();
try {
delivery.disposition(rejected);
delivery.settle();
} finally {
connection.unlock();
}
}
}