@@ -228,20 +228,6 @@ else if (cmd.equals("-logging"))
228228 iter .remove ();
229229 LogManager .getLogManager ().readConfiguration (new FileInputStream (filename ));
230230 }
231- else if (cmd .equals ("-thread_pool_size" )){
232- if (! iter .hasNext ()){
233- throw new Exception ("Missing -thread_pool_size value" );
234- }
235- iter .remove ();
236- try {
237- String size = iter .next ();
238- Integer threadPoolSize = Integer .valueOf (size );
239- properties .put ("thread_pool_size" , size );
240- } catch (NumberFormatException e ) {
241- logger .warning ("Specified thread pool size is not a number, will use value from properties or default value" );
242- }
243- iter .remove ();
244- }
245231 else
246232 throw new Exception ("Unknown option " + cmd );
247233 }
@@ -257,23 +243,17 @@ else if(cmd.equals("-thread_pool_size")){
257243 logger .info ("Alarm Logging Service (PID " + ProcessHandle .current ().pid () + ")" );
258244 context = SpringApplication .run (AlarmLoggingService .class , original_args );
259245
260- // Create scheduler with configured or default thread pool size
261- Integer threadPoolSize ;
262- try {
263- threadPoolSize = Integer .valueOf (properties .getProperty ("thread_pool_size" ));
264- } catch (NumberFormatException e ) {
265- logger .info ("Specified thread pool size is not a number, will default to 4" );
266- threadPoolSize = 4 ;
267- }
268- Scheduler = Executors .newScheduledThreadPool (threadPoolSize );
269-
270246 logger .info ("Properties:" );
271247 properties .forEach ((k , v ) -> { logger .info (k + ":" + v ); });
272248
273249 // Read list of Topics
274250 final List <String > topicNames = Arrays .asList (properties .getProperty ("alarm_topics" ).split ("," ));
275251 logger .info ("Starting logger for '..State': " + topicNames );
276252
253+ // Create scheduler with configured or default thread pool size
254+ int threadPoolSize = topicNames .size () * 2 ; // default to 2 threads per topic
255+ Scheduler = Executors .newScheduledThreadPool (threadPoolSize );
256+
277257 final boolean standalone = Boolean .valueOf (properties .getProperty ("standalone" ));
278258
279259 // If the standalone is true, ignore the Schedulers for AlarmMessageLogger and AlarmCmdLogger
0 commit comments