Skip to content

Jakarta 3.1 proper JMSX provider properties handling - #2864

Merged
mattrpav merged 9 commits into
apache:mainfrom
mattrpav:amq-jakarta-3.1-jmsx-properties
Nov 22, 2026
Merged

mattrpav merged 9 commits into
apache:mainfrom
mattrpav:amq-jakarta-3.1-jmsx-properties

Conversation

@mattrpav

@mattrpav mattrpav commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

This PR is ready and slides the behavior behind the strictCompliance flag.

Background

Provider-specific JMSX properties should not be allowed to be set by application code. ActiveMQ previously allowed this, so throwing an exception would be a SEMVER violation without a major version update.

This changes allows ActiveMQ to become more Jakarta compliant in a minor release, while also retaining the ability to perform an administrative copy at times that includes thos values. For example, a bridge or migration may want to copy those headers across from one JMS system to another.

Related

replaces [#1853]

pradeep85841 and others added 6 commits November 13, 2026 17:03
…a foreign message

On a strict connection, sending a message from another provider failed
with MessageNotWriteableException when that message listed a property
such as JMSXDeliveryCount. The conversion now leaves those properties
out on a strict connection.

transformMessage and copyProperties have an overload that takes a
strictComplianceOverride flag. True copies the provider-set values even
on a strict connection, for example when bridging. The consumer passes
true for a message returned by a consumer transformer, since that
message is on its way to the application.

The set of property names is renamed to JMSX_PROVIDER_PROPERTIES.
@mattrpav mattrpav added this to the Jakarta 3.1/JMS 2.0 support milestone Nov 13, 2026
@mattrpav mattrpav self-assigned this Nov 13, 2026
@mattrpav mattrpav changed the title Jakart 3.1 JMX Provider Properties handling Jakart 3.1 proper JMX provider properties handling Nov 13, 2026
@mattrpav mattrpav changed the title Jakart 3.1 proper JMX provider properties handling Jakarta 3.1 proper JMX provider properties handling Nov 13, 2026
@mattrpav mattrpav moved this from Backlog to In progress in Apache ActiveMQ v6.5.0 Nov 14, 2026
@mattrpav mattrpav moved this from In progress to In review in Apache ActiveMQ v6.5.0 Nov 14, 2026
@cshannon cshannon changed the title Jakarta 3.1 proper JMX provider properties handling Jakarta 3.1 proper JMSX provider properties handling Nov 15, 2026

@jeanouii jeanouii left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bridge or migration may want to copy those headers across from one JMS system to another

Any reason why only ActiveMQMessageConsumer passes true?

@mattrpav

Copy link
Copy Markdown
Contributor Author

a bridge or migration may want to copy those headers across from one JMS system to another

Any reason why only ActiveMQMessageConsumer passes true?

Yes. This is specifically for handling the conversion of a foreign JMS message by the consumer or when a message transformer is specified for message conversion. When a foreign JMS message is received, or a consumer transformer the provider specific properties need to be set on the newly constructed ActiveMQMessage.

@mattrpav
mattrpav requested a review from jeanouii November 17, 2026 18:29

@cshannon cshannon left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LLM found 2 issues to look at:

1. [P2] Consumer transformers lose provider-set properties in strict mode

Location:
ActiveMQMessageTransformation.java:199–217

The existing two-argument copyProperties() now skips provider-set properties whenever the target message belongs to a strict connection. This also affects consumer transformers using MessageTransformerSupport.copyProperties() to copy a received message into session.createTextMessage().

The override in ActiveMQMessageConsumer runs after the transformer, so it cannot recover the discarded properties. Native
ActiveMQMessage results also return directly from transformMessage().

Reproduced with an embedded broker:

  • After two session.recover() calls, the transformer receives JMSXDeliveryCount=3, but the application receives 2.
  • The transformer receives JMSXAppID="provider-app", but the application receives null.
  • Lenient mode preserves both values.

This loses provider metadata and corrupts delivery-attempt tracking.

Suggested fix: distinguish outbound conversion from inbound transformer copying. Preserve provider-set values on the consumer path, and add a regression using a transformer that copies into a session-created native message.

2. [P2] JMSProducer restrictions depend on the message implementation

Location:
ActiveMQMessage.java:531–536

The new check only executes on an ActiveMQ message setter. On a strict JMSContext, the following behavior is reproducible:

  • producer.setProperty("JMSXAppID", "app-set-value") succeeds.
  • Sending a native message created by context.createMessage() throws JMSRuntimeException.
  • Sending a foreign message succeeds, but JMSXAppID is silently discarded during conversion.

For the foreign message, the producer applies the property through that provider’s setter before ActiveMQ conversion removes it. The same strict producer configuration therefore fails for native messages but succeeds for foreign messages.

Suggested fix: validate provider-only names at the strict JMSProducer.setProperty() boundary. Add coverage for both native and foreign sends while retaining lenient behavior.

@cshannon

Copy link
Copy Markdown
Contributor

And here is a commit with the suggestions implemented to look at cshannon@ecbec08

@mattrpav
mattrpav requested a review from cshannon November 22, 2026 02:39

@cshannon cshannon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mattrpav
mattrpav merged commit bd612e8 into apache:main Nov 22, 2026
13 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in Apache ActiveMQ v6.5.0 Nov 22, 2026
@mattrpav
mattrpav deleted the amq-jakarta-3.1-jmsx-properties branch November 22, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants