dockerkubernetesjmshornetq

Share datafiles between two Docker containers running HornetQ


I have two instances of HornetQ, one that is meant to be called by the intranet to publish data, and one that is meant to be called from the internet, to read data.

Since I'm forced to specify a rmi hostname that after the JNDI lookup is used for invocations, and my public and private hostnames are different, I thought to start two containers of HornetQ inside a single Kubernetes POD, create two services and a route. The two containers are started on different ports and if I don't share the datafiles between them, it all works fine.

Since I need to share the datafiles between them, I created an emptyDir volume, and this is where I got stuck, because now one of them starts correctly, while the other deadlocks:

14:27:45,444 INFO  [org.hornetq.core.server] HQ221034: Waiting to obtain live lock

I've tried adding

   <shared-store>true</shared-store>
   <backup>${hornetq.backup:false}</backup>

to their configMap, but it had no effect.

How can I share the data between them? The classic clusters aren't suitable, because there is no "failover" in my scenario, and their configuration, at least in terms of the rmi public hostname, has to differ.

Thank you very much Roberto


Solution

  • The behavior you're seeing is expected. Two HornetQ instances cannot (and should not) share the same data concurrently. Since you're pointing both instances at the same directory you've implicitly configured shared-store high availability.

    Despite the fact that you say "classic clusters aren't suitable" it seems to me that's exactly what you need in order to share data between the nodes. Clustering and high availability (for failover) are configured independently. If you configure your cluster properly messages should flow between them based on demand. There won't be any failover and each can have their own hostname. You can read more about both clusters and high-availability in the HornetQ documentation.

    Lastly, why are you using HornetQ in the first place? The HornetQ code-base was donated to Apache ActiveMQ 5 years ago now and has carried on as the ActiveMQ Artemis broker. HornetQ hasn't had a release since then, but there's been over a dozen releases of ActiveMQ Artemis with lots of bug fixes and new features. I recommend you migrate to ActiveMQ Artemis ASAP.