[ 
https://issues.apache.org/jira/browse/ARTEMIS-4217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816212#comment-17816212
 ] 

Justin Bertram commented on ARTEMIS-4217:
-----------------------------------------

I was able to reproduce the problem with a relatively simple test in the 
test-suite based on the information that [~tabish] provided in his previous 
comment. The conversion from AMQP to core is happening because you're sending a 
message whose size is less than {{amqpMinLargeMessageSize}} but larger than the 
{{journal-buffer-size}}. Therefore, since the broker can't fit the message into 
the journal buffer it convert it into a _core_ large message and stores it 
directly to disk. Then the broker converts it back to AMQP to send it to your 
consumer. This is when/where the exceptions are happening.

Ideally the broker wouldn't covert the message to a _core_ large message but 
would instead keep it as an AMQP large message. I don't yet have code that will 
do that. However, I believe you can avoid the issue by adjusting your 
configuration. Currently you're using an {{amqpMinLargeMessageSize}} of 
{{5000000}} (i.e. 5MB) and the default {{journal-buffer-size}} of {{501760}} 
(i.e. 490KiB). You almost certainly don't want to be storing messages which are 
close to 5MB in memory so I recommend you lower your 
{{amqpMinLargeMessageSize}} to something a bit more reasonable. The default is 
{{102400}} (i.e. 100KiB) so maybe double it to be {{204800}}. If you find 
that's still too low for your liking then feel free to increase it and  the 
{{journal-buffer-size}} if necessary as well. However, keep in mind that the 
larger the {{amqpMinLargeMessageSize}} and {{journal-buffer-size}} is the more 
heap the broker will consume.

Let me know if that resolves the issue for you.

> AMQ111005: Failed to convert message. Sending it to Dead Letter Address.
> ------------------------------------------------------------------------
>
>                 Key: ARTEMIS-4217
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4217
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: AMQP
>    Affects Versions: 2.28.0
>         Environment: Windows Server 2022 21H2
> openjdk 19.0.1 2022-10-18
> OpenJDK Runtime Environment (build 19.0.1+10-21)
> OpenJDK 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)
>            Reporter: daves
>            Priority: Major
>         Attachments: ArtemisConvertError.zip, ArtemisReproMemory.zip, 
> image-2023-06-16-15-59-25-689.png, image-2023-06-16-15-59-25-721.png
>
>
> Some of the AMQP messages sent by my client never arrive at the consumer. In 
> the Artemis log I found the following exception:
> {noformat}
> 2023-03-23 18:06:58,084 WARN  
> [org.apache.activemq.artemis.protocol.amqp.logger] AMQ111005: Failed to 
> convert message. Sending it to Dead Letter Address. 
> org.apache.activemq.artemis.protocol.amqp.converter.coreWrapper.ConversionException:
>  java.nio.channels.ClosedChannelException
>      at 
> org.apache.activemq.artemis.protocol.amqp.converter.CoreAmqpConverter.fromCore(CoreAmqpConverter.java:318)
>  ~[artemis-amqp-protocol-2.28.0.jar:2.28.0]
>      at 
> org.apache.activemq.artemis.protocol.amqp.converter.CoreAmqpConverter.checkAMQP(CoreAmqpConverter.java:79)
>  ~[artemis-amqp-protocol-2.28.0.jar:2.28.0]     
>      at 
> org.apache.activemq.artemis.protocol.amqp.proton.ProtonServerSenderContext.executeDelivery(ProtonServerSenderContext.java:561)
>  ~[artemis-amqp-protocol-2.28.0.jar:2.28.0]     
>      at 
> org.apache.activemq.artemis.core.server.impl.MessageReferenceImpl.run(MessageReferenceImpl.java:131)
>  ~[artemis-server-2.28.0.jar:2.28.0]     
>      at 
> io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
>  ~[netty-common-4.1.86.Final.jar:4.1.86.Final]     
>      at 
> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
>  ~[netty-common-4.1.86.Final.jar:4.1.86.Final]     
>      at 
> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
>  ~[netty-common-4.1.86.Final.jar:4.1.86.Final]     
>      at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569) 
> ~[netty-transport-4.1.86.Final.jar:4.1.86.Final]     
>      at 
> io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
>  ~[netty-common-4.1.86.Final.jar:4.1.86.Final]     
>      at 
> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) 
> ~[netty-common-4.1.86.Final.jar:4.1.86.Final]     
>      at 
> org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
>  ~[artemis-commons-2.28.0.jar:?] Caused by: java.lang.RuntimeException: 
> java.nio.channels.ClosedChannelException     
>      at 
> org.apache.activemq.artemis.core.persistence.impl.journal.LargeBody.getBodyBufferSize(LargeBody.java:293)
>  ~[artemis-server-2.28.0.jar:2.28.0]     
>      at 
> org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageImpl.getBodyBufferSize(LargeServerMessageImpl.java:263)
>  ~[artemis-server-2.28.0.jar:2.28.0]     
>      at 
> org.apache.activemq.artemis.protocol.amqp.converter.coreWrapper.CoreBytesMessageWrapper.getBodyLength(CoreBytesMessageWrapper.java:98)
>  ~[artemis-amqp-protocol-2.28.0.jar:2.28.0]     
>      at 
> org.apache.activemq.artemis.protocol.amqp.converter.coreWrapper.CoreBytesMessageWrapper.getBinaryFromMessageBody(CoreBytesMessageWrapper.java:68)
>  ~[artemis-amqp-protocol-2.28.0.jar:2.28.0]     
>      at 
> org.apache.activemq.artemis.protocol.amqp.converter.coreWrapper.CoreBytesMessageWrapper.createAMQPSection(CoreBytesMessageWrapper.java:78)
>  ~[artemis-amqp-protocol-2.28.0.jar:2.28.0]     
>      at 
> org.apache.activemq.artemis.protocol.amqp.converter.CoreAmqpConverter.fromCore(CoreAmqpConverter.java:106)
>  ~[artemis-amqp-protocol-2.28.0.jar:2.28.0]     
>      ... 10 more 
> Caused by: java.nio.channels.ClosedChannelException     
>      at sun.nio.ch.FileChannelImpl.ensureOpen(FileChannelImpl.java:165) 
> ~[?:?]     
>      at sun.nio.ch.FileChannelImpl.size(FileChannelImpl.java:416) ~[?:?]     
>      at 
> org.apache.activemq.artemis.core.io.nio.NIOSequentialFile.size(NIOSequentialFile.java:339)
>  ~[artemis-journal-2.28.0.jar:2.28.0]     
>      at 
> org.apache.activemq.artemis.core.persistence.impl.journal.LargeBody.getBodyBufferSize(LargeBody.java:285)
>  ~[artemis-server-2.28.0.jar:2.28.0]     
>      at 
> org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageImpl.getBodyBufferSize(LargeServerMessageImpl.java:263)
>  ~[artemis-server-2.28.0.jar:2.28.0]     
>      at 
> org.apache.activemq.artemis.protocol.amqp.converter.coreWrapper.CoreBytesMessageWrapper.getBodyLength(CoreBytesMessageWrapper.java:98)
>  ~[artemis-amqp-protocol-2.28.0.jar:2.28.0]     
>      at 
> org.apache.activemq.artemis.protocol.amqp.converter.coreWrapper.CoreBytesMessageWrapper.getBinaryFromMessageBody(CoreBytesMessageWrapper.java:68)
>  ~[artemis-amqp-protocol-2.28.0.jar:2.28.0]     
>      at 
> org.apache.activemq.artemis.protocol.amqp.converter.coreWrapper.CoreBytesMessageWrapper.createAMQPSection(CoreBytesMessageWrapper.java:78)
>  ~[artemis-amqp-protocol-2.28.0.jar:2.28.0]     
>      at 
> org.apache.activemq.artemis.protocol.amqp.converter.CoreAmqpConverter.fromCore(CoreAmqpConverter.java:106)
>  ~[artemis-amqp-protocol-2.28.0.jar:2.28.0]
>      ... 10 more{noformat}
> I tried to reproduce the error with trace log level enabled, but the problem 
> never occurs with trace enabled (same message payload).  Maybe it is a timing 
> issue which not occurs when Artemis processes messages much slower due to 
> additional tracing...?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to