I have this kind of issue now in Production that sometimes occurring. For context, I'm using RabbitMQ and a Consumer called email-service, RabbitMQ is my messaging server and email-service are the one responsible for converting the HTML string to PDF and sending it via Email. I'm using this method XMLWorkerHelper.getInstance().parseXHtml()
to parse HTML to PDF and it stuck sometimes without error on the logs that made my rabbitMQ UNACK all the message that is currently queued. Please see the code below:
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
log.info( "END OF ByteArrayOutputStream" );
Document document = new Document();
log.info( "END OF Document" );
PdfWriter writer = PdfWriter.getInstance(document, outputStream);
log.info( "END OF PdfWriter" );
document.open();
log.info( "END OF document.open();" );
XMLWorkerHelper.getInstance().parseXHtml(writer, document,
new StringReader(fileAttachmentString)); // <--- sometimes stuck here
log.info( "END OF XMLWorkerHelper" );
document.close();
log.info( "END OF document.close();" );
byte[] bytes = outputStream.toByteArray();
log.info( "END OF byte[] bytes = outputStream.toByteArray();" );
DataSource dataSource = new ByteArrayDataSource(bytes, "application/pdf");
log.info( "END OF DataSource" );
attachmentPart.setDataHandler(new DataHandler(dataSource));
attachmentPart.setFileName(filename);
multipart.addBodyPart(attachmentPart);
If this occurred, I need to restart email-service again so it will consume again the messages in RabbitMQ. I don't know what causing why it stuck there in some time.
Note: Sending of email is working after restart but suddenly stucks because of the issue above.
Update:
Please check also the thread dump, I think it is stuck on the SocketInputStream.socketRead0 when I check the inner logs in Thread Dump.