it can be many reasons ...
most issue is the GC (garbage collection) of the JVM which stops all threads to cleanup the heap.
This might be a missconfiguration. You might enable the GC logging (see http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html) and check this first.
Thanks for pointing me in a direction.
I must say in most cases we do no experience any issues. Only when more messages have to be processed and be placed on the topic then this timing issue occurs.
Our code is pretty straight forward:
connection = connectionFactory.createTopicConnection();
session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
logger.info("Creating and sending the message...");
TextMessage message = session.createTextMessage(messageText);
TopicPublisher publisher = session.createPublisher(topic);
I will look into the GC logging and see what comes out and get back to you.
I found the error,
We use a mysql database in de background for our default jboss tables.
The tables JMS_MESSAGES and JMS_TRANSACTIONS are important for the creation of topic.
It seemed that these tables were screwed up. The tablespace was enormous for the 2 above tables as wel the indexspace. What caused long times for creations of topics.
After correcting the tablespaces and indexspaces, the issue was solved.
After some investigating these issues appearently can occure frequently with a mysql database.
In case other people incounter the same kind of issues.