Is there any way to disable or change minLargeMessageSize on server side? I have ActiveMQ Artemis 2.19 and Camel client with JMS component (ActiveMQJMSConnectionFactory). Setting property minLargeMessageSize does not help. Every message is sent has large message tag.
I tried:
- Setting property for acceptor
minLargeMessageSize. - Setting
minLargeMessageSizeproperty for JMS connection from the client side. - Setting
factory.setMinLargeMessageSize(1000000)also does not help. - Using
ActiveMQConnectionFactoryinstead ofActiveMQJMSConnectionFactory.
I want to send a 10MB file without using a "large" message.
This is my test route:
<bean id="artemisConnectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory">
<argument index="0" value="tcp://IP:61616"/>
<argument index="1" value="login"/>
<argument index="2" value="pass"/>
<property name="minLargeMessageSize" value="99999999"/>
</bean>
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="artemisConnectionFactory"/>
</bean>
<camelContext id="test-broker" xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="file:///home/dev/files"/>
<to uri="jms:test_queue"/>
</route>
<route>
<from uri="jetty:http://0.0.0.0:8182/testbroker"/>
<pollEnrich timeout="10">
<simple>jms:test_queue</simple>
</pollEnrich>
</route>
</camelContext>
Only bytes type fails with error.
2 Answers 2
i think the problem is in spring-jms(5.1.2.RELEASE) which is used in сamel-jms
I was able to reproduce the issue without camel
JmsTemplate jmsTemplate = new JmsTemplate();
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61616");
jmsTemplate.setConnectionFactory(cf);
Message message = jmsTemplate.receive("TEST_QUEUE");
BytesMessage bytesMessage = (BytesMessage) message;
int TEXT_LENGTH = new Long(bytesMessage.getBodyLength()).intValue();
byte[] textBytes = new byte[TEXT_LENGTH];
bytesMessage.readBytes(textBytes, TEXT_LENGTH);
FileOutputStream fos = new FileOutputStream("src\\test.pdf");
fos.write(textBytes);
fos.close();
queue TEST_QUEUE contains a message with the type bytes and when i try to read the message:
Exception in thread "main" java.lang.RuntimeException: AMQ219023: The large message lost connection with its session, either because of a rollback or a closed session
at org.apache.activemq.artemis.core.client.impl.ClientLargeMessageImpl.getBodyBuffer(ClientLargeMessageImpl.java:93)
at org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage.readBytes(ActiveMQBytesMessage.java:226)
at org.apache.camel.learn.SpringJms.main(SpringJms.java:25)
Caused by: ActiveMQIllegalStateException[errorType=ILLEGAL_STATE message=AMQ219023: The large message lost connection with its session, either because of a rollback or a closed session]
at org.apache.activemq.artemis.core.client.impl.LargeMessageControllerImpl.saveBuffer(LargeMessageControllerImpl.java:273)
at org.apache.activemq.artemis.core.client.impl.ClientLargeMessageImpl.checkBuffer(ClientLargeMessageImpl.java:159)
at org.apache.activemq.artemis.core.client.impl.ClientLargeMessageImpl.getBodyBuffer(ClientLargeMessageImpl.java:91)
... 2 more
artemis-jms-client-all/2.7.0
artemis broker 2.7.0
I don't think it's version dependent - i tried on camel 3 with broker 2.20+ and it was the same
UPD:
@justin-bertram about your last comment
https://github.com/tim08/camel_pollenrich_problem
how to use: move the file (I used 4mb) to src/data folder, make a get request to localhost:8081/test
first problem: not working parameter MinLargeMessageSize enter image description here
second problem: AMQ219023: The large message lost connection with its session, either because of a rollback or a closed session - when pollenrich
I used the latest versions apache camel and artemis broker
by the way when I used https://camel.apache.org/components/2.x/sjms-component.html- it worked without errors
1 Comment
I have a couple of workarounds for minLargeMessageSize to work correctly, tested on Camel 3.4.5 and Artemis 2.19.1.
- Use
SjmsComponentorSjms2Component(as @tim08 previously noted in his answer - https://stackoverflow.com/a/76723608/4169414) - Use
JmsComponentorAMQPComponent, but convert the message body to a string (.convertBodyTo(String.class)) before calling the producer. The message type in this case istextinstead ofbytesin the Artemis console. enter image description here
Comments
Explore related questions
See similar questions with these tags.
minLargeMessageSizeto something really large like9999999? You should be able to set this on the URL of the JMS connection (e.g.tcp://host:61616?minLargeMessageSize=9999999).