0

I'm just sending a string, I don't know why this is happening。 client-version: 4.5.2 server-version: 4.5.2

hope somebody can help me !

enter image description here

enter image description here

private void sendMission(String pushId) {

   try {

       Message message = new Message();

       message.setTopic(missionTpoic);

       message.setBody(pushId.getBytes("utf-8"));

       log.info("sendMission to MQ begin , message : {}", message);

       rocketMQService.getProducer().send(message, new SendCallback() {

           @Override

           public void onSuccess(SendResult sendResult) {

               log.info( "======== onSuccess ========== {}", sendResult);

           }

           @Override

           public void onException(Throwable e) {

               log.error( "======== onException ==========", e);

           }

       }, 10000L);

       log.info("sendMission to MQ end, message : {}", message);

   } catch (Exception e) {

       throw new BusinessRuntimeException(BaseExceptionCode.SYSTEM_ERROR.getAdminCode(), e, "Occur a error when push message into mq.");

   }

   log.info("sendMissionDone!!! pushId : {}", pushId);

}

The exception is as followed:

2021-03-26 16:06:13 {:} ERROR [AsyncSenderExecutor_1] c.p.b.p.c.SuperPushMissionExecutor:138 -- ======== onException ==========

java.util.ConcurrentModificationException: null

at java.util.HashMap$HashIterator.nextNode(HashMap.java:1445)

at java.util.HashMap$EntryIterator.next(HashMap.java:1479)

at java.util.HashMap$EntryIterator.next(HashMap.java:1477)

at org.apache.rocketmq.common.message.MessageDecoder.messageProperties2String(MessageDecoder.java:387)

at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendKernelImpl(DefaultMQProducerImpl.java:767)

at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:557)

at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.access$300(DefaultMQProducerImpl.java:90)

at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl$3.run(DefaultMQProducerImpl.java:491)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at java.lang.Thread.run(Thread.java:748)

1 Answers1

0

I don't know does the question is solved.It look like "rocketMQService.getProducer()" start a threadPool and send same "Message" using multi thread,and the "message.properties" is base on HashMap,when using thread to access HashMap it will throw ConcurrentModificationException.

so the solution is check you code on "rocketMQService.getProducer()" and don't use multi thread send same "Message".