Java Code Examples for org.apache.qpid.proton.engine.Sender#advance()
The following examples show how to use
org.apache.qpid.proton.engine.Sender#advance() .
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: DeferredSettlementTest.java From qpid-proton-j with Apache License 2.0 | 6 votes |
private Delivery sendMessageToClient(String deliveryTag, int messageBody) { byte[] tag = deliveryTag.getBytes(StandardCharsets.UTF_8); Message m = Proton.message(); m.setBody(new AmqpValue(messageBody)); byte[] encoded = new byte[BUFFER_SIZE]; int len = m.encode(encoded, 0, BUFFER_SIZE); assertTrue("given array was too small", len < BUFFER_SIZE); Sender serverSender = getServer().getSender(); Delivery serverDelivery = serverSender.delivery(tag); int sent = serverSender.send(encoded, 0, len); assertEquals("sender unable to send all data at once as assumed for simplicity", len, sent); boolean senderAdvanced = serverSender.advance(); assertTrue("sender has not advanced", senderAdvanced); return serverDelivery; }
Example 4
Source File: AmqpTransactionCoordinator.java From activemq-artemis with Apache License 2.0 | 6 votes |
private void sendTxCommand(Message message) throws IOException { int encodedSize = 0; byte[] buffer = OUTBOUND_BUFFER; while (true) { try { encodedSize = message.encode(buffer, 0, buffer.length); break; } catch (BufferOverflowException e) { buffer = new byte[buffer.length * 2]; } } Sender sender = getEndpoint(); sender.send(buffer, 0, encodedSize); sender.advance(); }
Example 5
Source File: AmqpTransactionCoordinator.java From qpid-jms with Apache License 2.0 | 6 votes |
private void sendTxCommand(Message message) throws ProviderException { int encodedSize = 0; byte[] buffer = OUTBOUND_BUFFER; while (true) { try { encodedSize = message.encode(buffer, 0, buffer.length); break; } catch (BufferOverflowException e) { buffer = new byte[buffer.length * 2]; } } Sender sender = getEndpoint(); sender.send(buffer, 0, encodedSize); sender.advance(); }
Example 6
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(); } }
Example 7
Source File: TransportImplTest.java From qpid-proton-j with Apache License 2.0 | 4 votes |
private Delivery sendMessage(Sender sender, String deliveryTag, String messageContent) { byte[] tag = deliveryTag.getBytes(StandardCharsets.UTF_8); Message m = Message.Factory.create(); m.setBody(new AmqpValue(messageContent)); byte[] encoded = new byte[BUFFER_SIZE]; int len = m.encode(encoded, 0, BUFFER_SIZE); assertTrue("given array was too small", len < BUFFER_SIZE); Delivery delivery = sender.delivery(tag); int sent = sender.send(encoded, 0, len); assertEquals("sender unable to send all data at once as assumed for simplicity", len, sent); boolean senderAdvanced = sender.advance(); assertTrue("sender has not advanced", senderAdvanced); return delivery; }