private void getToken(final ProtonConnection openCon, final Future<HonoUser> authResult) { final ProtonMessageHandler messageHandler = (delivery, message) -> { final String type = MessageHelper.getApplicationProperty( message.getApplicationProperties(), AuthenticationConstants.APPLICATION_PROPERTY_TYPE, String.class); if (AuthenticationConstants.TYPE_AMQP_JWT.equals(type)) { final String payload = MessageHelper.getPayloadAsString(message); if (payload != null) { final HonoUser user = new HonoUserAdapter() { @Override public String getToken() { return payload; } }; LOG.debug("successfully retrieved token from Authentication service"); authResult.complete(user); } else { authResult.fail("message from Authentication service contains no body"); } } else { authResult.fail("Authentication service issued unsupported token [type: " + type + "]"); } }; openReceiver(openCon, messageHandler).compose(openReceiver -> { LOG.debug("opened receiver link to Authentication service, waiting for token ..."); }, authResult); }