File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
queue-based-load-leveling/src/main/java/com/iluwatar/queue/load/leveling Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -40,21 +40,17 @@ public ServiceExecutor(MessageQueue msgQueue) {
4040 }
4141
4242 /** The ServiceExecutor thread will retrieve each message and process it. */
43+ @ Override
44+
4345 public void run () {
4446 try {
4547 while (!Thread .currentThread ().isInterrupted ()) {
46- var msg = msgQueue .retrieveMsg ();
47-
48- if (null != msg ) {
49- LOGGER .info (msg + " is served." );
50- } else {
51- LOGGER .info ("Service Executor: Waiting for Messages to serve .. " );
52- }
53-
54- Thread .sleep (1000 );
48+ var msg = msgQueue .retrieveMsg (); // blocks internally
49+ LOGGER .info (msg + " is served." );
5550 }
5651 } catch (Exception e ) {
57- LOGGER .error (e .getMessage ());
52+ Thread .currentThread ().interrupt ();
53+ LOGGER .error ("Error while processing message" , e );
5854 }
5955 }
6056}
You can’t perform that action at this time.
0 commit comments