use of org.fusesource.stomp.client.Promise in project camel by apache.
the class StompEndpoint method doStart.
@Override
protected void doStart() throws Exception {
final Promise<CallbackConnection> promise = new Promise<>();
stomp = new Stomp(configuration.getBrokerURL());
stomp.setLogin(configuration.getLogin());
stomp.setPasscode(configuration.getPasscode());
if (configuration.getSslContextParameters() != null) {
stomp.setSslContext(configuration.getSslContextParameters().createSSLContext(getCamelContext()));
}
stomp.connectCallback(promise);
if (configuration.getHost() != null && !configuration.getHost().isEmpty()) {
stomp.setHost(configuration.getHost());
}
connection = promise.await();
connection.getDispatchQueue().execute(new Task() {
@Override
public void run() {
connection.receive(new Callback<StompFrame>() {
@Override
public void onFailure(Throwable value) {
if (started.get()) {
connection.close(null);
}
}
@Override
public void onSuccess(StompFrame value) {
if (!consumers.isEmpty()) {
Exchange exchange = createExchange();
exchange.getIn().setBody(value.content());
for (StompConsumer consumer : consumers) {
consumer.processExchange(exchange);
}
}
}
});
connection.resume();
}
});
}
Aggregations