use of org.apache.avro.ipc.HttpServer in project camel by apache.
the class AvroListener method initAndStartServer.
/**
* Initializes and starts http or netty server on basis of transport protocol from configuration.
*
*
* @param configuration
* @return Initialized and started server
* @throws java.io.IOException
*/
private Server initAndStartServer(AvroConfiguration configuration) throws Exception {
SpecificResponder responder;
Server server;
if (configuration.isReflectionProtocol()) {
responder = new AvroReflectResponder(configuration.getProtocol(), this);
} else {
responder = new AvroSpecificResponder(configuration.getProtocol(), this);
}
if (AVRO_HTTP_TRANSPORT.equalsIgnoreCase(configuration.getTransport().name())) {
server = new HttpServer(responder, configuration.getPort());
} else if (AVRO_NETTY_TRANSPORT.equalsIgnoreCase(configuration.getTransport().name())) {
server = new NettyServer(responder, new InetSocketAddress(configuration.getHost(), configuration.getPort()));
} else {
throw new IllegalArgumentException("Unknown transport " + configuration.getTransport());
}
server.start();
return server;
}
use of org.apache.avro.ipc.HttpServer in project camel by apache.
the class AvroHttpProducerTest method initializeServer.
@Override
protected void initializeServer() throws IOException {
if (server == null) {
server = new HttpServer(new SpecificResponder(KeyValueProtocol.PROTOCOL, keyValue), avroPort);
server.start();
}
if (serverReflection == null) {
serverReflection = new HttpServer(new ReflectResponder(TestReflection.class, testReflection), avroPortReflection);
serverReflection.start();
}
}
Aggregations