I am running ActiveMQ Artemis (2.18.0) on CentOS
OS: CentOS Linux release 7.9.2009 (Core)
Kernel: Linux 3.10.0-1160.31.1.el7.x86_64
Since I am running a kernel version newer than 2.6 on an x86_64 architecture then based on the documentation I only need to ensure that libaio is installed:
yum install libaio
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.1000mbps.com
* centos-sclo-rh: mirror.seedvps.com
* centos-sclo-sclo: mirror.seedvps.com
* extras: mirror.seedvps.com
* updates: mirror.seedvps.com
Package libaio-0.3.109-13.el7.x86_64 already installed and latest version
In the broker.xml
I set the journal type to AIO:
<journal-type>ASYNCIO</journal-type>
I start the broker programmatically:
broker = new EmbeddedActiveMQ();
broker.setConfigResourcePath(fileConfig);
broker.start();
However, I get the following warning:
org.apache.activemq.artemis.core.server : AMQ222018: AIO was not located on this platform, it will fall back to using pure Java NIO. If your platform is Linux, install LibAIO to enable the AIO journal
What could be the case?
2
Answers
The warning occurs because in order to integrate properly with AIO three conditions must be met:
java.library.path
Java system property must be set to the directory with the proper shared object (e.g.libartemis-native-64.so
).In this case the third condition isn't met. Normally
java.library.path
is set on startup by thebin/artemis
script, but this isn't done when embedding ActiveMQ Artemis into a Java application.If using
EmbeddedActiveMQ
you can add AIO support in one of the following ways:Manually
apache-artemis-2.18.0-bin.zip
).apache-artemis-2.18.0/bin/lib/linux-x86_64
).Docker Container
Add the library to the container and startup java with the
-Djava.library.path
parameter.Programmatically
If you feel comfortably (this works for me) you can load the library in runtime:
For more info on loading
java.library.path
at runtime see this SO article.By starting the broker yourself programmatically you miss an important configuration detail performed by the
artemis run
command which sets thejava.library.path
system property to include the proper JNI library for AIO integration. Therefore you’ll need to do this manually when you start your own Java application which starts the embedded instance of ActiveMQ Artemis. The library you need is in$ARTEMIS_HOME/bin/lib/linux-x86_64
.The documentation you cited references this fact saying:
If you then follow the library path link you’ll see this: