This example shows how to send large messages between Apache Camel and ActiveMQ Artemis. When we say large messages we refer to messages with sizes of GB.
You should be able to run Camel and Artemis in JVMs with lower memory such as 256/512mb etc, and still be able to send messages in GB of sizes between them.
This works by spool big messages to disk. Artemis spool large messages to its
data/large-messages directory, and Camel uses stream caching to spool to a temporary directory during routing.
The example is run using Maven.
First compile the example by entering:
To automate downloading, unpacking and configuration of Apache ActiveMQ Artemis with latest defined version a special profile is added. It's necessary to run following Maven command for do this during example install:
mvn install -P artemis
To start configured ActiveMQ Artemis instance in a shell use:
$ target/artemis-instance/bin/artemis run
Which startup ActiveMQ Artemis in the foreground and keeps it running until you hit ctrl+c to shutdown ActiveMQ Artemis.
Before running this example, then ensure the JVM has limited memory by executing
And then start the Camel application:
You can then copy files to
target/inbox folder which is send to Artemis, and then back again to Camel and written to the
This should work for small and big files such as files with sizes of GB. The JVM should not run out of memory.
To stop the example hit ctrl+c. If you restart it and resume entering numbers you should see that it remembered previously entered values, as it uses a persistent store.
You can browse the Artemis web console: http://localhost:8161/console to see activity such as number of consumers and producers. You can also delete all messages from queues which is a handy operation.
If you hit an problems please let us know on the Camel Forums http://camel.apache.org/discussion-forums.html
Please help us make Apache Camel better - we appreciate any feedback you may have. Enjoy!
The Camel riders!