As far as I'm aware there is no optimization to avoid serialization for ObjectMessage instances even within the same JVM. I think such an optimization is theoretically feasible, but it would not be straightforward, and it would be optimizing a use-case that's well-known for bad performance. In short, if you want good performance don't use ObjectMessage.
The "Performance Tuning" chapter in the ActiveMQ Artemis documentation [1] states: Avoid ObjectMessage. ObjectMessage is convenient but it comes at a cost. The body of a ObjectMessage uses Java serialization to serialize it to bytes. The Java serialized form of even small objects is very verbose so takes up a lot of space on the wire, also Java serialization is slow compared to custom marshalling techniques. Only use ObjectMessage if you really can't use one of the other message types, i.e. if you really don't know the type of the payload until run-time. There is even a comment on the ActiveMQ Artemis implementation of ObjectMessage (i.e. org.apache.activemq.artemis.jms.client.ActiveMQObjectMessage) [2]: /** * ActiveMQ Artemis implementation of a JMS ObjectMessage. * <br> * Don't used ObjectMessage if you want good performance! * <p> * Serialization is slooooow! */ I have personally warned folks away from ObjectMessage many times on Stack Overflow not just because of the performance issues, but because of security issues as well. In short, don't use ObjectMessage if at all possible. Justin [1] https://activemq.apache.org/components/artemis/documentation/latest/perf-tuning.html#tuning-jms [2] https://github.com/apache/activemq-artemis/blob/main/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQObjectMessage.java#L33 On Fri, Mar 17, 2023 at 5:52 PM Walter Krix (Nokia) <walter.k...@nokia.com> wrote: > Dear ActiveMQ Artemis Developers, > > > I am writing to inquire about the configuration of the ActiveMQ Artemis > subsystem in Wildfly 26.1.2, with regards to serialization and > deserialization of complex Java objects. > > > Currently, when using Artemis on Wildfly and sending complex Java objects, > the message is automatically serialized. However, I would like to disable > this feature if possible, as I believe it should not be necessary since > both Artemis and Wildfly are running within the same JVM. > > > I would greatly appreciate it if you could provide me with information on > how to achieve this configuration. Any guidance, documentation or resources > you can offer to assist me in this matter would be most helpful. > > > Thank you for your time and attention to this matter. I look forward to > hearing back from you soon. > > > Sincerely, > > Walter Krix > > >