While this I don't know how to do this with ActiveMQ, you can see a blog post how to design a MQTT database logger in this blog post. This blog post uses HiveMQ but perhaps there is something similar for ActiveMQ available?
If you really don't want to go with a plugin approach (hint: you should!), then you can always have a MQTT subscriber which logs to a database. Please see the blog post linked above for a discussion why this isn't optimal.