本文整理汇总了Java中org.apache.qpid.proton.engine.Delivery.pending方法的典型用法代码示例。如果您正苦于以下问题:Java Delivery.pending方法的具体用法?Java Delivery.pending怎么用?Java Delivery.pending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.qpid.proton.engine.Delivery
的用法示例。
在下文中一共展示了Delivery.pending方法的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: onDelivery
import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
@Override
public void onDelivery(Event event) {
Receiver recv = (Receiver)event.getLink();
Delivery delivery = recv.current();
if (delivery.isReadable() && !delivery.isPartial()) {
int size = delivery.pending();
byte[] buffer = new byte[size];
int read = recv.recv(buffer, 0, buffer.length);
recv.advance();
Message msg = Proton.message();
msg.decode(buffer, 0, read);
System.out.println(((AmqpValue)msg.getBody()).getValue());
}
}
示例4: onDelivery
import org.apache.qpid.proton.engine.Delivery; //导入方法依赖的package包/类
@Override
public void onDelivery(Event event) {
final String methodName = "onDelivery";
logger.entry(this, methodName, event);
EngineConnection engineConnection = (EngineConnection)event.getConnection().getContext();
Delivery delivery = event.getDelivery();
if (event.getLink() instanceof Sender) {
SendRequest sr = engineConnection.inProgressOutboundDeliveries.remove(delivery);
Exception exception = null;
if (delivery.getRemoteState() instanceof Rejected) {
final Rejected rejected = (Rejected) delivery.getRemoteState();
final ErrorCondition error = rejected.getError();
if (error == null || error.getDescription() == null) {
exception = new Exception("Message was rejected");
} else {
exception = new Exception(error.getDescription());
}
} else if (delivery.getRemoteState() instanceof Released) {
exception = new Exception("Message was released");
} else if (delivery.getRemoteState() instanceof Modified) {
exception = new Exception("Message was modified");
}
if (!sr.retainLink) {
event.getLink().close();
event.getLink().free();
}
sr.getSender().tell(new SendResponse(sr, exception), this);
} else if (delivery.isReadable() && !delivery.isPartial()) { // Assuming link instanceof Receiver...
Receiver receiver = (Receiver)event.getLink();
int amount = delivery.pending();
byte[] data = new byte[amount];
receiver.recv(data, 0, amount);
receiver.advance();
EngineConnection.SubscriptionData subData = engineConnection.subscriptionData.get(event.getLink().getName());
subData.unsettled++;
QOS qos = delivery.remotelySettled() ? QOS.AT_MOST_ONCE : QOS.AT_LEAST_ONCE;
subData.subscriber.tell(new DeliveryRequest(data, qos, event.getLink().getName(), delivery, event.getConnection()), this);
}
logger.exit(this, methodName);
}