We have client rest application communicating with calculator application via hazelcast iQueue. Object from the rest is added into the queue and on calculator application there is listener to receive the object and delete it from queue. Everything is working fine for normal usage. But when requests starts coming under 0.3seconds between them the objects stuck in the queue and when they go huge number the whole application is slowed (not only this queue/listener)
Here is the code for deleting the object from the queue:
public void deleteFromQueue(String queueId, Object object) throws NullPointerException, ClassCastException {
GenericMessage<?> incomeMessage = (GenericMessage<?>) object;
boolean removed = false;
removed = hazelcastInstance.getQueue(queueId).remove(object);
if (!removed) {
Iterator<Object> iterator = hazelcastInstance.getQueue(queueId).iterator();
while (iterator.hasNext()) {
Object next = iterator.next();
GenericMessage<?> message = (GenericMessage<?>) next;
if (incomeMessage.getHeaders().getKey().equalsIgnoreCase(message.getHeaders().getKey())) {
removed = hazelcastInstance.getQueue(queueId).remove(next);
break;
}
}
if (!removed) {
if (hazelcastInstance.getQueue(queueId).size() == 1) {
hazelcastInstance.getQueue(queueId).poll();
}
}
}
}
Here is the listener configuration:
@Bean(name = "threadPoolTaskExecutor")
public Executor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.setMaxPoolSize(10);
executor.setWaitForTasksToCompleteOnShutdown(true);
executor.setQueueCapacity(15);
executor.initialize();
return executor;
}
Because of that issue with objects stucking into the queue I’m getting this info message:
2024-04-30 00:00:01,578 INFO c.h.l.StandardLoggerFactory$StandardLogger [hz.hazelcast_calculator.HealthMonitor] [127.0.0.1]:0000 [NAME] [5.3.6] processors=8, physical.memory.total=31.3G, physical.memory.free=589.2M, swap.space.total=0, swap.space.free=0, heap.memory.used=8.6G, heap.memory.free=13.9G, heap.memory.total=22.5G, heap.memory.max=25.0G, heap.memory.used/total=38.20%, heap.memory.used/max=34.41%, minor.gc.count=142365, minor.gc.time=2012868ms, major.gc.count=2186, major.gc.time=3189851ms, unknown.gc.count=8, unknown.gc.time=38ms, load.process=0.00%, load.system=99.55%, load.systemAverage=14.04, thread.count=439, thread.peakCount=469, cluster.timeDiff=0, event.q.size=0, executor.q.async.size=0, executor.q.client.size=0, executor.q.client.query.size=0, executor.q.client.blocking.size=0, executor.q.query.size=0, executor.q.scheduled.size=0, executor.q.io.size=0, executor.q.system.size=0, executor.q.operations.size=1, executor.q.priorityOperation.size=0, operations.completed.count=1655285419, executor.q.mapLoad.size=0, executor.q.mapLoadAllKeys.size=0, executor.q.cluster.size=0, executor.q.response.size=0, operations.running.count=0, operations.pending.invocations.percentage=0.00%, operations.pending.invocations.count=1, proxy.count=953, clientEndpoint.count=3, connection.active.count=3, client.connection.count=2, connection.count=2