本文整理汇总了Java中org.apache.qpid.proton.engine.Receiver类的典型用法代码示例。如果您正苦于以下问题:Java Receiver类的具体用法?Java Receiver怎么用?Java Receiver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Receiver类属于org.apache.qpid.proton.engine包,在下文中一共展示了Receiver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDelivery
import org.apache.qpid.proton.engine.Receiver; //导入依赖的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.Receiver; //导入依赖的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: Pool
import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
public Pool(Collector collector, final Router router) {
this.collector = collector;
connections = new HashMap<String,Connection>();
if (router != null) {
outgoingResolver = new LinkResolver<Sender>() {
public Sender resolve(String address) {
return router.getOutgoing(address).choose();
}
};
incomingResolver = new LinkResolver<Receiver>() {
public Receiver resolve(String address) {
return router.getIncoming(address).choose();
}
};
} else {
outgoingResolver = new LinkResolver<Sender>() {
public Sender resolve(String address) { return null; }
};
incomingResolver = new LinkResolver<Receiver>() {
public Receiver resolve(String address) { return null; }
};
}
}
示例4: onUnhandled
import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void onUnhandled(Event event) {
int window = this.window;
Link link = event.getLink();
switch(event.getType()) {
case LINK_LOCAL_OPEN:
case LINK_REMOTE_OPEN:
case LINK_FLOW:
case DELIVERY:
if (link instanceof Receiver) {
this.drained += link.drained();
if (this.drained == 0) {
topup((Receiver)link, window);
}
}
break;
default:
break;
}
}
示例5: 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();
}
}
示例6: processFlowUpdates
import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void processFlowUpdates(AmqpConnection connection) throws IOException {
if (pullRequest != null || stopRequest != null) {
Receiver receiver = getEndpoint();
if (receiver.getRemoteCredit() <= 0 && receiver.getQueued() == 0) {
if (pullRequest != null) {
pullRequest.onSuccess();
pullRequest = null;
}
if (stopRequest != null) {
stopRequest.onSuccess();
stopRequest = null;
}
}
}
LOG.trace("Consumer {} flow updated, remote credit = {}", getSubscriptionName(), getEndpoint().getRemoteCredit());
super.processFlowUpdates(connection);
}
示例7: remoteLinkOpened
import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
protected void remoteLinkOpened(Link link) throws Exception {
AMQPSessionContext protonSession = getSessionExtension(link.getSession());
link.setSource(link.getRemoteSource());
link.setTarget(link.getRemoteTarget());
if (link instanceof Receiver) {
Receiver receiver = (Receiver) link;
if (link.getRemoteTarget() instanceof Coordinator) {
Coordinator coordinator = (Coordinator) link.getRemoteTarget();
protonSession.addTransactionHandler(coordinator, receiver);
} else {
protonSession.addReceiver(receiver);
}
} else {
Sender sender = (Sender) link;
protonSession.addSender(sender);
}
}
示例8: 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();
}
}
}
示例9: add
import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
private void add(Receiver rcv) {
String address = getAddress(rcv);
Routes<Receiver> routes = incoming.get(address);
if (routes == null) {
routes = new Routes<Receiver>();
incoming.put(address, routes);
}
routes.add(rcv);
}
示例10: remove
import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
private void remove(Receiver rcv) {
String address = getAddress(rcv);
Routes<Receiver> routes = incoming.get(address);
if (routes != null) {
routes.remove(rcv);
if (routes.size() == 0) {
incoming.remove(address);
}
}
}
示例11: 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);
}
}
}
示例12: onLinkFlow
import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void onLinkFlow(Event evt) {
Link link = evt.getLink();
if (link instanceof Receiver) {
Receiver receiver = (Receiver) link;
if (!receiver.draining()) {
receiver.getSession().getConnection().close();
}
}
}
示例13: onLinkLocalOpen
import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void onLinkLocalOpen(Event evt) {
Link link = evt.getLink();
if (link instanceof Receiver) {
topUp((Receiver) link);
}
}
示例14: onLinkRemoteOpen
import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void onLinkRemoteOpen(Event evt) {
Link link = evt.getLink();
if (link instanceof Receiver) {
topUp((Receiver) link);
}
}
示例15: onLinkFlow
import org.apache.qpid.proton.engine.Receiver; //导入依赖的package包/类
@Override
public void onLinkFlow(Event evt) {
Link link = evt.getLink();
if (link instanceof Receiver) {
topUp((Receiver) link);
}
}