Why ActiveMQ doesn't and console still shows messages after deleting db-*.log files from KahaDB - activemq

I am using KahaDB as a persistent storage to save message in ActiveMQ 5.16.4.
<persistenceAdapter>
<kahaDB directory="${activemq.data}/kahadb"
checkForCorruptJournalFiles="true"
checksumJournalFiles="true"
ignoreMissingJournalfiles="true"
/>
</persistenceAdapter>
I'm sending persistent messages and then while the broker is running I'm deleting the KahaDB log files (db-1.log in below picture) which are supposed to hold the queue's messages. However, but deleting the log file doesn't seems to do anything. In the ActiveMQ console I still see the persistent messages, and I can also send more messages which get picked up by connected consumer from Spring Boot apps. I thought deleting those log files will get rid of messages that are pending in queue or break ActiveMQ. Any idea why it isn't happening?
Inside KahaDB folder:

ActiveMQ doesn't treat KahaDB like a SQL database where messages are stored and retrieved during runtime. Generally speaking, ActiveMQ keeps all of its messages in memory and it uses KahaDB is a journal to store messages which it will reload into memory if the broker fails or is restarted administratively. Deleting KahaDB's underlying data won't impact what is in the broker's memory, and it's not clear why you would ever want to do this in the first place.
If you want to remove the messages from a queue during runtime you can do so administratively via the web console. Deleting the KahaDB log files is not the recommended way to do this.

Related

How to persist retained message between activemq broker restart?

I have a status topic, published using QoS 1 & retained message = true over ActiveMQ (docker rmohr/activemq:5.15.9). I want my dashboard to be able to late subscribe to the topics and always receive the last published message.
The retained functionality seems to work well but the message seems to be wiped out upon ActiveMQ broker restart.
If I stop publishing to the topic, restart the broker, and try to late subscribe, I do not receive the last message (the one that was retained before the broker restart).
I use the default container configuration (kahadb & filesystem directory mounted for data/ and conf/). I thought that the retained meesage would be in kahadb but it is empty. The ActiveMQ ui also shows empty queue for topic after broker restart.
It is expected behavior? Can I achieve retained message persistence through broker restart with ActiveMQ? How should I proceed?
The retain message should not be lost under any circumstances unless the client publishes an empty retain message
You can switch to EMQ x to avoid this problem. You can store the data on disk or in your favorite database

Get dump of fuse activemq messages

I am running a production application with fuse esb and using fuse provided activemq queues. There are 100k messages in one of my queues and I need to get a dump of those messages without removing them from the queue. What is the method to get a dump of those messages.
I used activemq:browse karaf command and directed output to file.But it did not give me all the messages. Only 4000 messages were written to a file.
ActiveMQ cannot browse extremely deep Queues so you won't likely be able to view them all. The browse operation is limited to what can fit into the broker memory and by the maxBrowsePageSize setting.
There is no tooling to dump the contents of the message store offered in ActiveMQ. A broker is not a database and should not be treated as one, messages are meant for consumers to consume.

Format ActiveMQ server like hdfs node format?

Is there any option or command line available to format (erase all data)ActiveMQ server like hdfs node format?
I have deleted the all Queues in ActiveMQ but still is has consumer 47% , how can format all data ?
Simple answer: Remove the kahadb folder pointed out by your persistence configuration and restart ActiveMQ. It will be recreated on startup if not present.
Longer answer: As long as there is a message or something going on, ActiveMQ will lock transaction log files where that message is. The log files will be cleaned up with some interval when there are no unconsumed messages within them. That might include unconsumed messages in durable subscriptions and other things.
You can also set the broker attribute deleteAllMessagesOnStartup in configuration and restart. That can be useful in some situations.

message deleted from queue

I have used BlockingQueue implementation to process my events by services from a queue. However in case if the server goes down, all my events from that queue are getting deleted and hence I am missing events to process. (I am looking for some internal DB where server can store the event/messages from queue and if server goes down and up again, it can load all events/messages to process again, without manually intervention).
Any help on this. I am not sure if I should use Apache ActiveMQ. I am using apache servicemix.
Thanks in advance.
I can not answer about how to do this with BlockingQueue.
But ActiveMQ has two features that you will benefit from:
Persistent Queues and possibly you might also want to look at Durable Queues
It has a built in database that just does this under the hood and allows messages to be persisted in queue even if broker or consumer has to restart.

How can messages in Activemq queue/topics be persisted while using KahaDB?

More specifically, right now when activemq is restarted, the enqueue/dequeue message count for queue and topic changes back to 0 but I would like activemq to persist messages using KahaDB so that even after an activemq restart the counter doesn't switch back to 0 but shows the cumulative count. Any pointers will really help.
I am using activemq version - 5.4.3 and all default settings.
Thank you in advance.
If you have KahaDB configured and are sending Messages with the persistent property enabled (the default) then they will be stored and reloaded for all the Queues or Topics that had durable subscribers.