0Respostas

Pessoal,

Aqui estamos usando o lumis 11.1 e temos casos intermitentes de erro ao enviar e-mails com anexo pela API do lumis.

Os casos acontecem quando a mensagem tem algum anexo e é enviada para mais de um destinatário, segue a exception:

2021-02-26 15:15:46,703 ERROR      [SendMailThread-80808080774B40A20177DF8C94152310] lumis.portal.sendmail.SendMailManager - Could not send mail: Mail[80808080774B40A20177DF8C94152311]: Subject "xxx"; From "a@a.com.br"; To "b@b.com.br"; Cc ""; Bcc ""; Reply-To ""
java.lang.IllegalStateException: java.sql.SQLRecoverableException: Closed Connection
	at lumis.portal.sendmail.dao.hibernate.MailAttachment.getContentInputStream(MailAttachment.java:87)
	at lumis.portal.sendmail.smtp.SmtpMailSender.sendMail(SmtpMailSender.java:90)
	at lumis.portal.sendmail.SendMailManager.sendMail(SendMailManager.java:112)
	at lumis.portal.sendmail.SendMailManager.sendQueuedMail(SendMailManager.java:204)
	at lumis.portal.sendmail.SendMailManager.processNextQueuedMail(SendMailManager.java:264)
	at lumis.portal.sendmail.SendMailThread.run(SendMailThread.java:66)
Caused by: java.sql.SQLRecoverableException: Closed Connection
	at oracle.sql.BLOB.getDBAccess(BLOB.java:1289)
	at oracle.sql.BLOB.getBinaryStream(BLOB.java:294)
	at org.hibernate.lob.SerializableBlob.getBinaryStream(SerializableBlob.java:62)
	at lumis.portal.sendmail.dao.hibernate.MailAttachment.getContentInputStream(MailAttachment.java:81)
	... 5 more
2021-02-26 15:15:46,704 ERROR      [SendMailThread-80808080774B40A20177DF8C94152310] lumis.portal.UnexpectedException - lumis.portal.UnexpectedException created
lumis.portal.UnexpectedException: STR_UNEXPECTED_EXCEPTION
	at lumis.portal.sendmail.SendMailManager.sendMail(SendMailManager.java:123)
	at lumis.portal.sendmail.SendMailManager.sendQueuedMail(SendMailManager.java:204)
	at lumis.portal.sendmail.SendMailManager.processNextQueuedMail(SendMailManager.java:264)
	at lumis.portal.sendmail.SendMailThread.run(SendMailThread.java:66)
Caused by: java.lang.IllegalStateException: java.sql.SQLRecoverableException: Closed Connection
	at lumis.portal.sendmail.dao.hibernate.MailAttachment.getContentInputStream(MailAttachment.java:87)
	at lumis.portal.sendmail.smtp.SmtpMailSender.sendMail(SmtpMailSender.java:90)
	at lumis.portal.sendmail.SendMailManager.sendMail(SendMailManager.java:112)
	... 3 more
Caused by: java.sql.SQLRecoverableException: Closed Connection
	at oracle.sql.BLOB.getDBAccess(BLOB.java:1289)
	at oracle.sql.BLOB.getBinaryStream(BLOB.java:294)
	at org.hibernate.lob.SerializableBlob.getBinaryStream(SerializableBlob.java:62)
	at lumis.portal.sendmail.dao.hibernate.MailAttachment.getContentInputStream(MailAttachment.java:81)
	... 5 more
2021-02-26 15:15:46,705 ERROR      [SendMailThread-80808080774B40A20177DF8C94152310] lumis.portal.sendmail.SendMailManager - Error when trying to send mail
lumis.portal.UnexpectedException: STR_UNEXPECTED_EXCEPTION
	at lumis.portal.sendmail.SendMailManager.sendMail(SendMailManager.java:123)
	at lumis.portal.sendmail.SendMailManager.sendQueuedMail(SendMailManager.java:204)
	at lumis.portal.sendmail.SendMailManager.processNextQueuedMail(SendMailManager.java:264)
	at lumis.portal.sendmail.SendMailThread.run(SendMailThread.java:66)
Caused by: java.lang.IllegalStateException: java.sql.SQLRecoverableException: Closed Connection
	at lumis.portal.sendmail.dao.hibernate.MailAttachment.getContentInputStream(MailAttachment.java:87)
	at lumis.portal.sendmail.smtp.SmtpMailSender.sendMail(SmtpMailSender.java:90)
	at lumis.portal.sendmail.SendMailManager.sendMail(SendMailManager.java:112)
	... 3 more
Caused by: java.sql.SQLRecoverableException: Closed Connection
	at oracle.sql.BLOB.getDBAccess(BLOB.java:1289)
	at oracle.sql.BLOB.getBinaryStream(BLOB.java:294)
	at org.hibernate.lob.SerializableBlob.getBinaryStream(SerializableBlob.java:62)
	at lumis.portal.sendmail.dao.hibernate.MailAttachment.getContentInputStream(MailAttachment.java:81)
	... 5 more

Essa mensagem possuia mais 4 destinatários que receberam normalmente. Porque parece que ele envia em separado mesmo utilizando:

mail.getDestinations().addAll(destinationSet);

Onde destinationSet é uma Collection de IMailDestination.

Não temos nenhuma ocorrencia de erros do comunicação com banco no momento do envio, e essa exception pelo que pesquisei parece relacionada a utilizar o mesmo inputStream mais de uma vez.

Eu tentei reduzir o número de threads de envio e aumentar o intervalo entre os envios para tentar mitigar alguma situação de concorrencia mas o erro se mantém.

Gabriel Barbosa
Em 04/03/21 13:23

0 Respostas

Acompanhar pergunta

Receba atualizações e novas respostas por e-mail, e ajude a resolver as dúvidas da comunidade.
Quero acompanhar essa pergunta