Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » ConcurrentModificationException in deliverMessage(error while subscribing and sending messages)
ConcurrentModificationException in deliverMessage [message #1804443] Tue, 26 March 2019 08:18
Angela Stempfel is currently offline Angela StempfelFriend
Messages: 1
Registered: March 2019
Junior Member
hi all

i have a scheduled job which sends multiple messages and subscribes to a topic for each of these message:

 @Scheduled(cron = "${}")
    public void sendMessages() {
        List<ScheduledJob> foundJobsToExecute = scheduledJobRepository.findByAusfuehrungsZeitpunktLessThanEqualAndStatus(, JobStatus.ANSTEHEND);"started cron job, found {} jobs to execute",  foundJobsToExecute.size());
        foundJobsToExecute.forEach(job -> asyncService.executeSendAndSubscribePerJob(job));

 public void executeSendAndSubscribePerJob(ScheduledJob job) {

        try {



            String sendTopic = String.format(VERSION_TOPIC, job.getRessourcenUniqueIdentifier());
            String responseTopic = "reply_" + job.getCorrelationId();
  "sending message {} to topic {} ", job.getMessagePayload(), sendTopic);

            mqttPahoClient.subscribe(responseTopic, message -> {
                tempService.doStuff(message, job.getId(), responseTopic);

            MqttMessage messageToSend = new MqttMessage(job.getMessagePayload().getBytes(), 2, true, createMqttProperties(responseTopic));
            mqttPahoClient.send(sendTopic, messageToSend);

        } catch (MqttException e) {


but now it seems that the paho client isnt able to subscribe and deliver messages in parallel, because i get a concurrent modification exception while doing it:
Caused by: Untranslated MqttException - RC: 0 (0) - java.util.ConcurrentModificationException
	... 1 more
Caused by: java.util.ConcurrentModificationException
	at java.base/java.util.HashMap$HashIterator.nextNode(
	at java.base/java.util.HashMap$
	at java.base/java.util.HashMap$
	at org.eclipse.paho.mqttv5.client.internal.CommsCallback.deliverMessage(
	at org.eclipse.paho.mqttv5.client.internal.CommsCallback.handleMessage(
	... 1 more

I think it's the same problem as reported here:
Is there a way around this issue or to fix it? Any help appreciated

regards angela

Previous Topic:paho async c++ client, no timeout on MQTTAsync_sendMessage?
Next Topic:Proxy aware
Goto Forum:

Current Time: Sun Oct 25 05:16:05 GMT 2020

Powered by FUDForum. Page generated in 0.01988 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top