use of com.ning.http.client.AsyncHttpClient in project rxrabbit by meltwater.
the class RxRabbitTests method setup.
@Before
public void setup() throws Exception {
dockerContainers.rabbit().assertUp();
rabbitTcpPort = dockerContainers.rabbit().tcpPort();
rabbitAdminPort = dockerContainers.rabbit().adminPort();
log.infoWithParams("****** Rabbit broker is up and running *****");
BrokerAddresses addresses = new BrokerAddresses("amqp://localhost:" + rabbitTcpPort);
channelFactory = new DefaultChannelFactory(addresses, connectionSettings);
consumerFactory = new DefaultConsumerFactory(channelFactory, consumeSettings);
publisherFactory = new DefaultPublisherFactory(channelFactory, publishSettings);
httpClient = new AsyncHttpClient();
messagesSeen.clear();
createQueues(channelFactory, inputQueue, new Exchange(inputExchange));
publisher = publisherFactory.createPublisher();
RxJavaHooks.setOnIOScheduler(null);
}
use of com.ning.http.client.AsyncHttpClient in project pinpoint by naver.
the class NingAsyncHttpClientIT method test.
@Test
public void test() throws Exception {
AsyncHttpClient client = new AsyncHttpClient();
try {
Future<Response> f = client.preparePost(webServer.getCallHttpUrl()).addParameter("param1", "value1").execute();
Response response = f.get();
} finally {
client.close();
}
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
String destinationId = webServer.getHostAndPort();
String httpUrl = webServer.getCallHttpUrl();
verifier.verifyTrace(event("ASYNC_HTTP_CLIENT", AsyncHttpClient.class.getMethod("executeRequest", Request.class, AsyncHandler.class), null, null, destinationId, annotation("http.url", httpUrl)));
verifier.verifyTraceCount(0);
}
use of com.ning.http.client.AsyncHttpClient in project apex-malhar by apache.
the class WebSocketOutputOperator method openConnection.
private void openConnection() throws IOException, ExecutionException, InterruptedException, TimeoutException {
final AsyncHttpClientConfigBean config = new AsyncHttpClientConfigBean();
config.setIoThreadMultiplier(ioThreadMultiplier);
config.setApplicationThreadPool(Executors.newCachedThreadPool(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName(ClassUtils.getShortClassName(this.getClass()) + "-AsyncHttpClient-" + count++);
return t;
}
}));
client = new AsyncHttpClient(config);
// force reparse after deserialization
uri = URI.create(uri.toString());
LOG.info("Opening URL: {}", uri);
connection = client.prepareGet(uri.toString()).execute(new WebSocketUpgradeHandler.Builder().addWebSocketListener(new WebSocketTextListener() {
@Override
public void onMessage(String string) {
}
@Override
public void onOpen(WebSocket ws) {
LOG.debug("Connection opened");
}
@Override
public void onClose(WebSocket ws) {
LOG.debug("Connection closed.");
}
@Override
public void onError(Throwable t) {
LOG.error("Caught exception", t);
}
}).build()).get(5, TimeUnit.SECONDS);
}
use of com.ning.http.client.AsyncHttpClient in project apex-malhar by apache.
the class WebSocketInputOperator method run.
@Override
public void run() {
try {
connectionClosed = false;
AsyncHttpClientConfigBean config = new AsyncHttpClientConfigBean();
config.setIoThreadMultiplier(ioThreadMultiplier);
config.setApplicationThreadPool(Executors.newCachedThreadPool(new ThreadFactory() {
private long count = 0;
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName(ClassUtils.getShortClassName(this.getClass()) + "-AsyncHttpClient-" + count++);
return t;
}
}));
if (client != null) {
client.closeAsynchronously();
}
client = new AsyncHttpClient(config);
connection = client.prepareGet(uri.toString()).execute(new WebSocketUpgradeHandler.Builder().addWebSocketListener(new WebSocketTextListener() {
@Override
public void onMessage(String string) {
try {
T o = convertMessage(string);
if (!(skipNull && o == null)) {
outputPort.emit(o);
}
} catch (IOException ex) {
LOG.error("Got exception: ", ex);
}
}
@Override
public void onOpen(WebSocket ws) {
LOG.debug("Connection opened");
}
@Override
public void onClose(WebSocket ws) {
LOG.debug("Connection connectionClosed.");
connectionClosed = true;
}
@Override
public void onError(Throwable t) {
LOG.error("Caught exception", t);
}
}).build()).get(5, TimeUnit.SECONDS);
} catch (Exception ex) {
LOG.error("Error reading from " + uri, ex);
if (client != null) {
client.close();
}
connectionClosed = true;
}
}
Aggregations