diff --git a/org.eclipse.scout.rt.mom.api/src/main/java/org/eclipse/scout/rt/mom/api/PublishInput.java b/org.eclipse.scout.rt.mom.api/src/main/java/org/eclipse/scout/rt/mom/api/PublishInput.java
index 65da10e5f58..f85d7102c75 100644
--- a/org.eclipse.scout.rt.mom.api/src/main/java/org/eclipse/scout/rt/mom/api/PublishInput.java
+++ b/org.eclipse.scout.rt.mom.api/src/main/java/org/eclipse/scout/rt/mom/api/PublishInput.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2023 BSI Business Systems Integration AG
+ * Copyright (c) 2010, 2026 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -131,7 +131,7 @@ public PublishInput withProperty(final String name, final String value) {
/**
* Sets multiple properties to be included as message property.
*
- * This is a convenience method calling {@link #withProperties(String, String)} multiple times.
+ * This is a convenience method calling {@link #withProperty(String, String)} multiple times.
*/
public PublishInput withProperties(final Map props) {
if (props != null) {
diff --git a/org.eclipse.scout.rt.mom.jms/src/main/java/org/eclipse/scout/rt/mom/jms/JmsMessageWriter.java b/org.eclipse.scout.rt.mom.jms/src/main/java/org/eclipse/scout/rt/mom/jms/JmsMessageWriter.java
index ed297a9bfed..4ce6b5f9b5b 100644
--- a/org.eclipse.scout.rt.mom.jms/src/main/java/org/eclipse/scout/rt/mom/jms/JmsMessageWriter.java
+++ b/org.eclipse.scout.rt.mom.jms/src/main/java/org/eclipse/scout/rt/mom/jms/JmsMessageWriter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2023 BSI Business Systems Integration AG
+ * Copyright (c) 2010, 2026 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -29,6 +29,7 @@
import org.eclipse.scout.rt.platform.BEANS;
import org.eclipse.scout.rt.platform.Bean;
import org.eclipse.scout.rt.platform.exception.PlatformException;
+import org.eclipse.scout.rt.platform.exception.ProcessingException;
/**
* Allows to write a JMS message.
@@ -43,6 +44,7 @@ public class JmsMessageWriter {
protected IMarshaller m_marshaller;
protected Map m_marshallerContext;
protected IDataObjectMapper m_contextDataObjectMapper;
+ protected long m_maxMessageSize = 0;
/**
* Initializes this writer.
@@ -56,6 +58,11 @@ protected JmsMessageWriter init(final Session session, final IMarshaller marshal
return this;
}
+ public JmsMessageWriter withMaxMessageSize(final long maxMessageSize) {
+ this.m_maxMessageSize = maxMessageSize;
+ return this;
+ }
+
/**
* Creates the message of the given type.
*/
@@ -91,10 +98,18 @@ public JmsMessageWriter writeTransferObject(final Object transferObject) throws
switch (m_marshaller.getMessageType()) {
case MESSAGE_TYPE_TEXT:
- writeTextMessage((TextMessage) m_message, (String) transportObject);
+ String text = (String) transportObject;
+ if (m_maxMessageSize > 0 && text != null && m_maxMessageSize < text.length()) {
+ throw new ProcessingException("Message too large: {} > {}.", text.length(), m_maxMessageSize);
+ }
+ writeTextMessage((TextMessage) m_message, text);
break;
case MESSAGE_TYPE_BYTES:
- writeBytesMessage((BytesMessage) m_message, (byte[]) transportObject);
+ byte[] data = (byte[]) transportObject;
+ if (m_maxMessageSize > 0 && data != null && m_maxMessageSize < data.length) {
+ throw new ProcessingException("Message too large: {} > {}.", data.length, m_maxMessageSize);
+ }
+ writeBytesMessage((BytesMessage) m_message, data);
break;
case MESSAGE_TYPE_NO_PAYLOAD:
break;
diff --git a/org.eclipse.scout.rt.mom.jms/src/main/java/org/eclipse/scout/rt/mom/jms/JmsMomImplementor.java b/org.eclipse.scout.rt.mom.jms/src/main/java/org/eclipse/scout/rt/mom/jms/JmsMomImplementor.java
index a341cb9f707..05ac1c73e1a 100644
--- a/org.eclipse.scout.rt.mom.jms/src/main/java/org/eclipse/scout/rt/mom/jms/JmsMomImplementor.java
+++ b/org.eclipse.scout.rt.mom.jms/src/main/java/org/eclipse/scout/rt/mom/jms/JmsMomImplementor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2023 BSI Business Systems Integration AG
+ * Copyright (c) 2010, 2026 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -131,6 +131,11 @@ public class JmsMomImplementor implements IMomImplementor {
*/
public static final String JMS_REQUEST_CANCELLATION_MESSAGE_CONSUMER_JOB_RECEIVE_TIMEOUT = "scout.mom.jms.requestCancellationMessageConsumerJobReceiveTimeout";
+ /**
+ * Key to set {@link #m_requestMaxMessageSize}
+ */
+ public static final String JMS_REQUEST_MAX_MESSAGE_SIZE = "scout.mom.jms.requestMaxMessageSize";
+
/**
* Key to set {@link #m_subscriptionAwaitStartedSeconds}, if value is not set {@link #WAIT_TIME_INFINITE} is used as a
* default to wait infinitely (the {@link #WAIT_TIME_INFINITE} value may also be used to configure an infinite wait
@@ -169,6 +174,7 @@ public class JmsMomImplementor implements IMomImplementor {
protected long m_messageConsumerJobReceiveTimeout = 0L;
protected long m_replyMessageConsumerJobReceiveTimeout = 0L;
protected long m_requestCancellationMessageConsumerJobReceiveTimeout = 0L;
+ protected long m_requestMaxMessageSize = 0L;
@Override
public void init(final Map