apache/beam · error · JmsIOException
Error creating TextMessage
Error message
Error creating TextMessage
What it means
TextMessageMapper.apply() creates a JMS TextMessage from a String value via session.createTextMessage() and setText(); a JMSException during this is rethrown as a JmsIOException with message "Error creating TextMessage". This converts the checked JMSException into an unchecked error suitable for Beam pipelines.
Solutions
- Check the chained JMSException cause for session/connection state issues.
- Verify broker connectivity and reconnect/retry configuration for the JMS write transform.
- Ensure the producer's session is recreated on failure (JmsIO handles this internally; don't share sessions across threads).
Defensive patterns
Strategy: try-catch
Try / catch
try { Message m = textMessageMapper.apply(value, session); }
catch (JmsIOException e) {
if (e.getCause() instanceof JMSException) {
// session likely closed; recreate session and retry
}
} Prevention
- Don't share JMS sessions across threads.
- Enable broker reconnect/failover settings (e.g. failover:// transport for ActiveMQ).
- Keep producer sessions short-lived or recreate on failure.
When it happens
Trigger: Session is closed/broken when the mapper runs (session.createTextMessage() throws), or msg.setText() fails due to an invalid/broken session or message state.
Common situations: Broker connection dropped mid-pipeline so sessions are invalid; long-lived producers hitting idle connection timeouts; broker restarts.
Related errors
- Error creating JMS session
- An error occurred
- Attempting to add message
- ConnectionFactory does not exist. If using expansion…
- Error connecting to JMS
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/8a601d120583c6ad.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/io/jms/src/main/java/org/apache/beam/sdk/io/jms/TextMessageMapper.java:39
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
import org.apache.beam.sdk.transforms.SerializableBiFunction;
/**
* The TextMessageMapper takes a {@link String} value, a {@link javax.jms.Session} and returns a
* {@link javax.jms.TextMessage}.
*/
public class TextMessageMapper implements SerializableBiFunction<String, Session, Message> {
@Override
public Message apply(String value, Session session) {
try {
TextMessage msg = session.createTextMessage();
msg.setText(value);
return msg;
} catch (JMSException e) {
throw new JmsIOException("Error creating TextMessage", e);
}
}
}
View on GitHub (pinned to 12126d8942)