Java Code Examples for org.apache.qpid.proton.engine.Event#getLink()
The following examples show how to use
org.apache.qpid.proton.engine.Event#getLink() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Spout.java From qpid-proton-j with Apache License 2.0 | 6 votes |
@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++; } } }
Example 2
Source File: Send.java From qpid-proton-j with Apache License 2.0 | 6 votes |
@Override public void onLinkFlow(Event event) { Sender snd = (Sender)event.getLink(); if (snd.getCredit() > 0) { byte[] msgData = new byte[1024]; int length; while(true) { try { length = message.encode(msgData, 0, msgData.length); break; } catch(BufferOverflowException e) { msgData = new byte[msgData.length * 2]; } } byte[] tag = String.valueOf(nextTag++).getBytes(); Delivery dlv = snd.delivery(tag); snd.send(msgData, 0, length); dlv.settle(); snd.advance(); snd.close(); snd.getSession().close(); snd.getSession().getConnection().close(); } }
Example 3
Source File: FlowController.java From qpid-proton-j with Apache License 2.0 | 6 votes |
@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; } }
Example 4
Source File: Server.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Override public void onLinkFlow(Event evt) { Link link = evt.getLink(); if (link instanceof Sender) { Sender snd = (Sender) link; send(router.getAddress(snd), snd); } }
Example 5
Source File: Handshaker.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@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(); } }
Example 6
Source File: Handshaker.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Override public void onLinkRemoteClose(Event evt) { Link link = evt.getLink(); if (link.getLocalState() != EndpointState.CLOSED) { link.close(); } }
Example 7
Source File: Drain.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@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); } } }
Example 8
Source File: Drain.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@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(); } } }
Example 9
Source File: FlowController.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Override public void onLinkLocalOpen(Event evt) { Link link = evt.getLink(); if (link instanceof Receiver) { topUp((Receiver) link); } }
Example 10
Source File: FlowController.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Override public void onLinkRemoteOpen(Event evt) { Link link = evt.getLink(); if (link instanceof Receiver) { topUp((Receiver) link); } }
Example 11
Source File: FlowController.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Override public void onLinkFlow(Event evt) { Link link = evt.getLink(); if (link instanceof Receiver) { topUp((Receiver) link); } }
Example 12
Source File: FlowController.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Override public void onDelivery(Event evt) { Link link = evt.getLink(); if (link instanceof Receiver) { topUp((Receiver) link); } }
Example 13
Source File: Recv.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@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()); } }
Example 14
Source File: Handshaker.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Override public void onLinkRemoteOpen(Event event) { Link link = event.getLink(); if (link.getLocalState() == EndpointState.UNINITIALIZED) { if (link.getRemoteSource() != null) { link.setSource(link.getRemoteSource().copy()); } if (link.getRemoteTarget() != null) { link.setTarget(link.getRemoteTarget().copy()); } } open(link); }
Example 15
Source File: ReactorImpl.java From qpid-proton-j with Apache License 2.0 | 5 votes |
private Handler eventHandler(Event event) { Handler result; if (event.getLink() != null) { result = BaseHandler.getHandler(event.getLink()); if (result != null) return result; } if (event.getSession() != null) { result = BaseHandler.getHandler(event.getSession()); if (result != null) return result; } if (event.getConnection() != null) { result = BaseHandler.getHandler(event.getConnection()); if (result != null) return result; } if (event.getTask() != null) { result = BaseHandler.getHandler(event.getTask()); if (result != null) return result; } if (event.getSelectable() != null) { result = BaseHandler.getHandler(event.getSelectable()); if (result != null) return result; } return handler; }
Example 16
Source File: ReactorTest.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Override public void onLinkFlow(Event event) { Sender link = (Sender)event.getLink(); while (link.getCredit() > 0 && remaining > 0) { Delivery dlv = link.delivery(new byte[0]); assertNotNull(dlv); dlv.settle(); link.advance(); --remaining; } if (remaining == 0) { event.getConnection().close(); } }