本文整理汇总了Java中org.apache.qpid.proton.engine.Link类的典型用法代码示例。如果您正苦于以下问题:Java Link类的具体用法?Java Link怎么用?Java Link使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Link类属于org.apache.qpid.proton.engine包,在下文中一共展示了Link类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDelivery
import org.apache.qpid.proton.engine.Link; //导入依赖的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: resolve
import org.apache.qpid.proton.engine.Link; //导入依赖的package包/类
private <T extends Link> T resolve(String remote, String local,
LinkResolver<T> resolver,
LinkConstructor<T> constructor) {
String host = remote.substring(2).split("/", 2)[0];
T link = resolver.resolve(remote);
if (link == null) {
Connection conn = connections.get(host);
if (conn == null) {
conn = Connection.Factory.create();
conn.collect(collector);
conn.setHostname(host);
conn.open();
connections.put(host, conn);
}
Session ssn = conn.session();
ssn.open();
link = constructor.create(ssn, remote, local);
link.open();
}
return link;
}
示例3: onLinkFlow
import org.apache.qpid.proton.engine.Link; //导入依赖的package包/类
@Override
public void onLinkFlow(Event evt) {
Link link = evt.getLink();
if (link instanceof Sender) {
Sender sender = (Sender) link;
while ((sent < count) && sender.getCredit() > 0) {
Delivery dlv = sender.delivery(String.format("spout-%s", sent).getBytes());
Message msg = new Message(String.format("Hello World! [%s]", sent));
byte[] bytes = msg.getBytes();
sender.send(bytes, 0, bytes.length);
sender.advance();
if (!quiet) {
System.out.println(String.format("Sent %s to %s: %s", new String(dlv.getTag()),
sender.getTarget().getAddress(), msg));
}
sent++;
}
}
}
示例4: getReactor
import org.apache.qpid.proton.engine.Link; //导入依赖的package包/类
@Override
public Reactor getReactor() {
if (context instanceof Reactor) {
return (Reactor) context;
} else if (context instanceof Task) {
return ((Task)context).getReactor();
} else if (context instanceof Transport) {
return ((TransportImpl)context).getReactor();
} else if (context instanceof Delivery) {
return ((Delivery)context).getLink().getSession().getConnection().getReactor();
} else if (context instanceof Link) {
return ((Link)context).getSession().getConnection().getReactor();
} else if (context instanceof Session) {
return ((Session)context).getConnection().getReactor();
} else if (context instanceof Connection) {
return ((Connection)context).getReactor();
} else if (context instanceof Selectable) {
return ((Selectable)context).getReactor();
}
return null;
}
示例5: onUnhandled
import org.apache.qpid.proton.engine.Link; //导入依赖的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;
}
}
示例6: remoteLinkOpened
import org.apache.qpid.proton.engine.Link; //导入依赖的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);
}
}
示例7: onLinkFlow
import org.apache.qpid.proton.engine.Link; //导入依赖的package包/类
@Override
public void onLinkFlow(Event evt) {
Link link = evt.getLink();
if (link instanceof Sender) {
Sender snd = (Sender) link;
send(router.getAddress(snd), snd);
}
}
示例8: add
import org.apache.qpid.proton.engine.Link; //导入依赖的package包/类
private void add(Link link) {
if (link instanceof Sender) {
add((Sender) link);
} else {
add((Receiver) link);
}
}
示例9: remove
import org.apache.qpid.proton.engine.Link; //导入依赖的package包/类
private void remove(Link link) {
if (link instanceof Sender) {
remove((Sender) link);
} else {
remove((Receiver) link);
}
}
示例10: onLinkRemoteOpen
import org.apache.qpid.proton.engine.Link; //导入依赖的package包/类
@Override
public void onLinkRemoteOpen(Event evt) {
Link link = evt.getLink();
if (link.getLocalState() == EndpointState.UNINITIALIZED) {
link.setSource(link.getRemoteSource());
link.setTarget(link.getRemoteTarget());
link.open();
}
}
示例11: onLinkRemoteClose
import org.apache.qpid.proton.engine.Link; //导入依赖的package包/类
@Override
public void onLinkRemoteClose(Event evt) {
Link link = evt.getLink();
if (link.getLocalState() != EndpointState.CLOSED) {
link.close();
}
}
示例12: onLinkLocalOpen
import org.apache.qpid.proton.engine.Link; //导入依赖的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);
}
}
}
示例13: onLinkFlow
import org.apache.qpid.proton.engine.Link; //导入依赖的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();
}
}
}
示例14: onLinkLocalOpen
import org.apache.qpid.proton.engine.Link; //导入依赖的package包/类
@Override
public void onLinkLocalOpen(Event evt) {
Link link = evt.getLink();
if (link instanceof Receiver) {
topUp((Receiver) link);
}
}
示例15: onLinkRemoteOpen
import org.apache.qpid.proton.engine.Link; //导入依赖的package包/类
@Override
public void onLinkRemoteOpen(Event evt) {
Link link = evt.getLink();
if (link instanceof Receiver) {
topUp((Receiver) link);
}
}