Reputation: 1
I am using LinkedBlockingQueue in my application. When the application is running the program waits at blockingqueue.take() statement. Even though after adding some objects into the queue, it is not progressing further.
The sample application:
public class DelegatorThread implements Runnable {
private static BlockingQueue<Alarm> pendingAlarmQueue = new LinkedBlockingQueue<Alarm>();
public void addJob(List<Alarm> alarms) throws InterruptedException {
pendingAlarmQueue.addAll(alarms);
}
public void run() {
while (true) {
try {
Alarm al = pendingAlarmQueue.take();
LOGGER.log(Level.Info, al.getSeverity());
} catch (InterruptedException | RemoteException | EInternalException | EsymacException e) {
LOGGER.log(Level.SEVERE, e.getMessage());
}
}
}
}
This is the consumer class
public class JsonToAlarmConverter {
private static DelegatorThread delegatorThread = null;
static {
delegatorThread = new DelegatorThread();
Thread t = new Thread(delegatorThread);
t.start();
}
public static synchronized void readJSONStringForRaise(String arrayOfAlarmObjects)
throws JSONException, IllegalArgumentException, InterruptedException {
addAlarminQueue(alarms);
}
}
For few entries into the queue, it is working as expected. After sometime it is not able to resume from take() even after adding some entries into the queue. Am I missing something here?
I have run this locally in eclipse and it is working fine. But when I run this in customer environment in server, the application freezes and only after restarting the server it works for few objects into the queue and again it stops working. Kindly help if I am using the BlockingQueue in any wrong way. No errors/exceptions seen in log files. It is not executing the statement after blockingQueue.take() and it is not processing any new entries into queue.
Upvotes: 0
Views: 46