I am working on a Java application which receives a list of messages and then inserts them in a queue. Is it possible to directly insert a list of messages in my Artemis JMS server (a kind of batch insert)? Or must I insert them one by one?
Using the JMS API you can create a “transacted” session, send a batch of messages, and then call
commit() on the session. From the point of view of the application it seems like messages are being sent one-by-one since
send() is called for every message. However, the most time consuming work only happens when
commit() is called which only happens once per batch. This is often done as a performance optimization especially for persistent messages to avoid the repeated blocking that happens on individual, non-transacted sends. Using transactions for batching purposes is discussed in the “Tuning JMS” section of the ActiveMQ Artemis performance tuning documentation.