[
Date Prev][Date Next][
Thread Prev][Thread Next][
Date Index][
Thread Index]
[
List Home]
|
Re: [messaging-dev] Impact of Read-only transactions on Messaging 3.1 applications?
|
Hi Matt,
the read-only configuration of a transaction is a semantic
statement i.e. that operations within that transaction should be
read-only.
The purpose would be to ensure that no modification operations
happen, as well as leveraging more optimized processing.
I don't know what "non-transacted set of reads across resources"
means exactly, but if implementations support a mode where
messages can be read without causing any sort of modification (due
to TX rollbacks or missing ACKs), then that is great. This is the
kind of thing that a read-only transaction would need. In
addition, it would be great if the JMS XAResource could ensure
that any write operations will throw exceptions when run inside of
a read-only transaction.
Regards,
Christian
Am 11.11.2025 um 17:09 schrieb Matt
Pavlovich:
Hi Christian-
I am struggling with understanding why would someone want to
use a transaction if it is read-only in the first place? How
would it behave differently from a non-transacted set of reads
across resources?
Thanks,
Matt
Hi Matt,
the main use case for read-only transactions is when
you only pull data without changing any state (no
insert/update/delete etc.) like any Web UI does.
Knowing that a transaction is read-only allows for
certain optimizations. Databases can avoid certain
kinds of locks or optimize the way such a transaction
is handled. Hibernate ORM for example can avoid dirty
tracking of entity objects. A datasource might hand
out connections to a read-only replica. I'm sure that
once we have this feature, we will come up with some
more clever optimizations.
I would say that the expectation on the JMS side is
that you implement this ExtendedXAResource interface,
to ensure such XASession objects that were put into
read-only mode throw errors if a mutation operation is
invoked. This will allow the JTA runtime to avoid
calling rollback() in the end. I don't know how
rollback() is implemented, but I would assume that a
commit, even if empty, would perform better generally.
Regards,
Christian
Am 10.11.2025 um 15:27
schrieb Matt Pavlovich:
Hi
Christian-
Thank you for the clarification— curiously, it
would be helpful to me to have a concrete use-case
to gain a deeper understanding of how that would
be used in JDBC or object store. If you have a doc
or link that you could share, I would appreciate
it!
Yes, currently the only area that the JMS
spec would be the JMS Browse. I do expect we’ll
add some acknowledgement modes to support
streaming-style use cases (ie
NO_ACKNOWLEDGEMENT) to consumer, but there is
nothing defined today.
Since a JMS Browse is read-only in any case,
I’m not sure what change would be expected if
the transaction is in a ‘readOnly’ configuration
vs a non-readOnly configuration.
In JMS, XA comes in at the ConnectionFactory
and ultimately a XASession is created. There
would be some weird things to sort out, since an
XASession is the junction across Producer,
Consumer and Browser sharing state (ie.. consume
a message and produce back to another queue on
the same broker in one transaction). Something
along the lines of— if the XAResource is
configured with ‘readOnly’ flag, creating a
producer or consumer off of that XASession
should throw an unsupported exception to signal
to the developer that they have an inconsistent
configuration.
-Matt
Hey all,
roughly speaking, the intent of
"read-only" is that operations within
such a transaction may not change data
in any form.
From a Jakarta Messaging perspective I
would say that the only reasonable usage
of a read-only transaction I can imagine
is with the QueueBrowser when messages
are just viewed, but never altered,
removed or moved.
Is it possible/sensible to have a
MessageConsumer that is read-only i.e.
never changes the state of messages but
just browses through them?Unless you
think it is useful, I think we can limit
the discussion to QueueBrowser.
The read-only nature does not impose
any other semantics. So any concerns
about race conditions, or more broadly
speaking transaction isolation, are
irrelevant.
Regards,
Christian
Am 08.11.2025
um 20:36 schrieb Matt Pavlovich via
messaging-dev:
Hi Scott-
What does ‘readOnly’ mean in this
context? More specifically— Do you
have a concrete use-case that would
involve messaging to provide
additional context?
Questions:
Is the intent to be ‘read-only’ or
’not impacting data change anywhere’?
What would be the expected behavior
if the first message on the queue was
malformed? Would the consumer reject
the message (then it would be the same
message the next time through) or move
the message to a dead-letter-queue and
try to see if the next message was
valid?
Is there an expectation that no
state changes (across all resources)
between ‘read’ message will be there
if a subsequent ‘write’ transaction
occurs after the readOnly completes?
(ie timing / race condition)
From the messaging perspective,
‘readOnly’ could be interpreted
different ways:.
1. A messaging consumer is
read-only from the perspective of the
queue-to-the-application.
- or -
2. A messaging consumer could be
considered a data changing operation
from the perspective of the queue-only
(the queue now has less message(s)).
- or -
3. Browse message(s) in a
transaction— no guarantee the they
will be there if the app tries to
immediately open a consumer after
browsing, since another consumer may
have processed them in the time
between (aka race condition).
Thanks,
Matt Pavlovich
Dear Jakarta
Messaging
specification team,
The Jakarta EE 12
Platform will include
Jakarta Transactions
2.1 which includes
readOnly hint added to
the
`jakarta.transaction.Transactional`
annotation [1][2]
which users.
I'm going to paste
some specification
text from the [3] pull
request that describes
the expected action to
be taken if read-only
mode is enabled for a
XAResource:
"
If the current
transaction is in the
read-only mode, the
transaction manager
tries to put the
enlisted resource in
the read-only mode by
invoking the
`ExtendedXAResource#setReadOnly`
method if it
implements the
`ExtendedXAResource`
interface. If the
`ExtendedXAResource`
cannot be put into
read-only mode or the
`XAResource` does not
implement the
`ExtendedXAResource`
interface, the
transaction manager
must roll back the
`XAResource` at
transaction commit.
"
Could the Messaging
specification team
please respond with
feedback on this new
read-only feature and
whether the EE 12 Platform
specification text
should mention any
Messaging features
that are not expected
to support read-only
transactions? If yes,
which Messaging
features will not work
with read-only
transactions? Also if
yes, should we open a
Messaging (4.0) issue
to add changes to
support read-only
transactions?
For example, could
QueueBrowser always
work in an active
transaction with a
(read-only mode enabled)
ExtendedXAResource? More
specifically could a
Messaging implementation
expect to update the
database during the queue
browse operation? I find
it unlikely that any
implementation would
update the (queue)
database during a browse
operation but want to hear
your feedback on whether
that would be allowed?
One possible reason for
updating the application
database is to save
QueueBrowser statistics to
the application database.
Perhaps we can come up
with generic EE 12
Platform text to describe
that any database update
performed against a
read-only Resource will
not be saved or something
like that to cover ^ and
operations like that.
Still, I'we are looking to
better understand the
possible cases and what
can be expected to
work/not work.
Thanks,
Scott
Note that there is
a Connectors issue [4]
open as well.
Thanks,
Scott
_______________________________________________
messaging-dev mailing list
messaging-dev@xxxxxxxxxxx
To unsubscribe from this list,
visit
https://accounts.eclipse.org
_______________________________________________
messaging-dev mailing list
messaging-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://accounts.eclipse.org
_______________________________________________
messaging-dev mailing list
messaging-dev@xxxxxxxxxxx
To unsubscribe from this list, visit
https://accounts.eclipse.org