use of io.vertx.proton.ProtonReceiver in project hono by eclipse.
the class AuthenticationServerClient method openReceiver.
private static Future<ProtonReceiver> openReceiver(final ProtonConnection openConnection, final ProtonMessageHandler messageHandler) {
final Promise<ProtonReceiver> result = Promise.promise();
final ProtonReceiver recv = openConnection.createReceiver(AuthenticationConstants.ENDPOINT_NAME_AUTHENTICATION);
recv.openHandler(result);
recv.handler(messageHandler);
recv.open();
return result.future();
}
use of io.vertx.proton.ProtonReceiver in project vertx-proton by vert-x3.
the class ProtonReceiverImplTest method testFlowWithExistingDrainOutstandingThrowsISE.
@Test
public void testFlowWithExistingDrainOutstandingThrowsISE() {
ProtonConnectionImpl conn = new ProtonConnectionImpl(null, null, null);
conn.bindClient(null, Mockito.mock(NetSocketInternal.class), null, new ProtonTransportOptions());
conn.fireDisconnect();
ProtonReceiver receiver = conn.createReceiver("address");
AtomicBoolean drain1complete = new AtomicBoolean();
receiver.setPrefetch(0);
receiver.flow(1);
receiver.drain(0, h -> {
drain1complete.set(true);
});
try {
receiver.flow(1);
fail("should have thrown due to outstanding drain operation");
} catch (IllegalStateException ise) {
// Expected
assertFalse("drain should not have been completed", drain1complete.get());
}
}
use of io.vertx.proton.ProtonReceiver in project vertx-proton by vert-x3.
the class ProtonReceiverImplTest method testDrainWithExistingDrainOutstandingThrowsISE.
@Test
public void testDrainWithExistingDrainOutstandingThrowsISE() {
ProtonConnectionImpl conn = new ProtonConnectionImpl(null, null, null);
conn.bindClient(null, Mockito.mock(NetSocketInternal.class), null, new ProtonTransportOptions());
conn.fireDisconnect();
ProtonReceiver receiver = conn.createReceiver("address");
AtomicBoolean drain1complete = new AtomicBoolean();
receiver.setPrefetch(0);
receiver.flow(1);
receiver.drain(0, h -> {
drain1complete.set(true);
});
try {
receiver.drain(0, h2 -> {
});
fail("should have thrown due to outstanding drain operation");
} catch (IllegalStateException ise) {
// Expected
assertFalse("first drain should not have been completed", drain1complete.get());
}
}
use of io.vertx.proton.ProtonReceiver in project enmasse-workshop by EnMasseProject.
the class AmqpClient method receive.
@Override
public void receive(String address) {
this.vertx.runOnContext(c -> {
if (!this.receivers.containsKey(address)) {
final ProtonReceiver receiver = this.connection.createReceiver(address);
receiver.handler((delivery, message) -> {
this.receiverHandler(receiver, delivery, message);
});
receiver.open();
}
});
}
use of io.vertx.proton.ProtonReceiver in project vertx-examples by vert-x3.
the class ReconnectReceiver method setupReceiver.
private void setupReceiver(ProtonConnection connection) {
ProtonReceiver receiver = connection.createReceiver(ADDRESS);
receiver.handler((delivery, msg) -> {
String content = (String) ((AmqpValue) msg.getBody()).getValue();
System.out.println("Received message with content: " + content);
// By default, receivers automatically accept (and settle) the delivery
// when the handler returns, if no other disposition has been applied.
// To change this and always manage dispositions yourself, use the
// setAutoAccept method on the receiver.
}).open();
}
Aggregations