public class QueryApplicationConfiguration
{
@Bean
- public QueryStreamProcessor streamProcessor(
+ public HostInfo applicationServer(
ServerProperties serverProperties,
- QueryApplicationProperties properties,
- ObjectMapper mapper,
- ConfigurableApplicationContext context) throws IOException
+ QueryApplicationProperties applicationProperties) throws IOException
{
String host;
if (serverProperties.getAddress() == null)
{
- HostInfo bootstrapServer = HostInfo.buildFromEndpoint(properties.getBootstrapServer());
+ HostInfo bootstrapServer = HostInfo.buildFromEndpoint(applicationProperties.getBootstrapServer());
Socket socket = new Socket();
socket.connect(new InetSocketAddress(bootstrapServer.host(), bootstrapServer.port()));
host = socket.getLocalAddress().getHostAddress();
Integer port = serverProperties.getPort() == null ? 8080 : serverProperties.getPort();
+ return new HostInfo(host, port);
+ }
+
+ @Bean
+ public QueryStreamProcessor streamProcessor(
+ QueryApplicationProperties applicationProperties,
+ HostInfo applicationServer,
+ ObjectMapper mapper,
+ ConfigurableApplicationContext context)
+ {
return new QueryStreamProcessor(
- properties.getApplicationId(),
- new HostInfo(host, port),
- properties.getBootstrapServer(),
- properties.getUsersInputTopic(),
- properties.getRankingInputTopic(),
+ applicationProperties.getApplicationId(),
+ applicationServer,
+ applicationProperties.getBootstrapServer(),
+ applicationProperties.getUsersInputTopic(),
+ applicationProperties.getRankingInputTopic(),
mapper,
context);
}