Error sending message - Direct buffer memory


We are using ( Solace + Spring JMS + Spring Boot + Pivotal Cloud Foundry ) to read a message from a queue and post to Topic. We are facing issue when reading 1 message of size - 7MB and posting to a topic. Smaller message size are working fine.

Below error when sending to topic
Error Message : javax.jms.JMSException: Error sending message - internal error (Direct buffer memory)
Could you please help on the next steps.

Error Stack:
Caused by: org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is javax.jms.JMSException: Error sending message - internal error (Direct buffer memory)
at ~[spring-jms-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
at ~[spring-jms-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
at org.springframework.jms.core.JmsTemplate.execute( ~[spring-jms-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
at org.springframework.jms.core.JmsTemplate.send( ~[spring-jms-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
at org.springframework.jms.core.JmsTemplate.convertAndSend( ~[spring-jms-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
at com.....inbound.service.impl.PublishServiceImpl.publishError( ~[classes/:na]
at com.....inbound.messaging.ErrorHandler.handleError( ~[classes/:na]
at com.....inbound.messaging.InboundListener.onMessage( ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_222]
at sun.reflect.NativeMethodAccessorImpl.invoke( ~[na:1.8.0_222]
at sun.reflect.DelegatingMethodAccessorImpl.invoke( ~[na:1.8.0_222]
at java.lang.reflect.Method.invoke( ~[na:1.8.0_222]
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke( ~[spring-messaging-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke( ~[spring-messaging-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
at org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter.invokeHandler( ~[spring-jms-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
... 10 common frames omitted
OUT Caused by: javax.jms.JMSException: Error sending message - internal error (Direct buffer memory)
OUT at com.solacesystems.jms.impl.JCSMPExceptionMapper.get( ~[sol-jms-10.3.1.jar!/:na]
OUT at com.solacesystems.jms.impl.Validator.createJMSException( ~[sol-jms-10.3.1.jar!/:na]
OUT at com.solacesystems.jms.SolMessageProducer.sendMessage( ~[sol-jms-10.3.1.jar!/:na]
OUT at com.solacesystems.jms.SolMessageProducer.send( ~[sol-jms-10.3.1.jar!/:na]
OUT at org.springframework.jms.connection.CachedMessageProducer.send( ~[spring-jms-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
OUT at org.springframework.jms.core.JmsTemplate.doSend( ~[spring-jms-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
OUT at org.springframework.jms.core.JmsTemplate.doSend( ~[spring-jms-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
OUT at org.springframework.jms.core.JmsTemplate.lambda$send$3( ~[spring-jms-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
OUT at org.springframework.jms.core.JmsTemplate.execute( ~[spring-jms-5.1.6.RELEASE.jar!/:5.1.6.RELEASE]
OUT ... 22 common frames omitted
OUT Caused by: java.lang.OutOfMemoryError: Direct buffer memory
OUT at java.nio.Bits.reserveMemory( ~[na:1.8.0_222]
OUT at java.nio.DirectByteBuffer.( ~[na:1.8.0_222]
OUT at java.nio.ByteBuffer.allocateDirect( ~[na:1.8.0_222]
OUT at com.solacesystems.jcsmp.protocol.smf.SimpleSmfClient.enqueueForNetOutput( ~[sol-jcsmp-10.3.1.jar!/:na]
OUT at com.solacesystems.jcsmp.protocol.smf.SimpleSmfClient.doSmfSharedWrite( ~[sol-jcsmp-10.3.1.jar!/:na]
OUT at com.solacesystems.jcsmp.protocol.impl.TcpClientChannel.sendPubMsgBuffer( ~[sol-jcsmp-10.3.1.jar!/:na]
OUT at com.solacesystems.jcsmp.protocol.impl.TcpClientChannel.send( ~[sol-jcsmp-10.3.1.jar!/:na]
OUT at com.solacesystems.jcsmp.impl.JCSMPXMLMessageProducer.sendMsgOnce( ~[sol-jcsmp-10.3.1.jar!/:na]
OUT at com.solacesystems.jcsmp.impl.JCSMPXMLMessageProducer.sendImpl( ~[sol-jcsmp-10.3.1.jar!/:na]
OUT at com.solacesystems.jcsmp.impl.JCSMPXMLMessageProducer.sendToDestination( ~[sol-jcsmp-10.3.1.jar!/:na]
OUT at com.solacesystems.jcsmp.impl.JCSMPXMLMessageProducer.sendToDestination( ~[sol-jcsmp-10.3.1.jar!/:na]
OUT at com.solacesystems.jcsmp.impl.JCSMPXMLMessageProducer.send( ~[sol-jcsmp-10.3.1.jar!/:na]
OUT at com.solacesystems.jms.impl.JCSMPMessageProducer.send( ~[sol-jms-10.3.1.jar!/:na]
OUT at com.solacesystems.jms.impl.TransactedMessageProducerAdapter.send( ~[sol-jms-10.3.1.jar!/:na]
OUT at com.solacesystems.jms.SolMessageProducer.sendMessage( ~[sol-jms-10.3.1.jar!/:na]
OUT ... 28 common frames omitted



  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 531 admin
    edited April 2020 #2

    Hi ruplim! That's an interesting sounding problem. I can see from the stack trace that there are issues in the underlying Solace JCSMP API during the send() call. When using the JCSMP API directly, there are some settings you can adjust when sending large messages (see: ), but I don't know if or how to adjust these when using Spring. So, to help with some debugging:


  • ruplim
    ruplim Member Posts: 6
    edited April 2020 #3

    Hello @Aaron
    This is happening when you are sending just a single 7 MB message? Only one??
    Yes - when we push 1 single message of around 7MB. The app is deployed in Pivotal Cloud Foundry. Seems the MaxDirectMemotySize setting in PCF is only 10MB. We tried setting solace property PUB_USE_INTERMEDIATE_DIRECT_BUF to false but it did not work. Any other properties provided by solace we can look into? Changing the PCF memory setting might not be possible.
    Since it doesn't happen with smaller sizes, at what point does it start happening? 4MB? 6MB?
    Smaller size go through. Most probably till it hits the PCF MaxDirectMemory

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 920 admin

    @Aaron, you can set Solace Java API properties via the Spring config file under as seen here if that helps?

    Honestly I haven't messed with many of these JCSMP settings, but maybe setting PUB_USE_INTERMEDIATE_DIRECT_BUF to false could help to avoid having an intermediate buffer. @Aaron - thoughts and any ramifications of doing that?

  • aharonmu
    aharonmu Member Posts: 1

    So what is right way to go?
    Disable it?
    Or increase the buffer?