wood burning stoves 2.0*
The moose likes JBoss/WildFly and the fly likes How to Delete Messages from Jboss Queue during jboss shut down? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "How to Delete Messages from Jboss Queue during jboss shut down?" Watch "How to Delete Messages from Jboss Queue during jboss shut down?" New topic
Author

How to Delete Messages from Jboss Queue during jboss shut down?

Csk Kumar
Greenhorn

Joined: Mar 07, 2011
Posts: 13
Hi,
In our application we are using Jboss Message Queue and the MDB's for message processing .
We have a requirement like when jboss shuts down the messages should be deleted from the queue so that next time when jboss starts there should not be any old messages in the queue.
Is there any configuartion in jboss ?
Please suggest me the way in which i can do this?

If no configuartions present then please suggest me whether we can do it using EJB @Service destroy method?

We are using EJB Services for instantiating MDB's by pushing some dummy messages.
@Service
@Management(ServiceOneManagement.class)

void create() throws Exception;

Can we use void destroy(); method to delete the messages?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Possible kludge: add to the run script a call to another script that deletes the messaging tables from the database. Then when JBoss AS starts up, messaging will create new, empty tables.


JBoss In Action
Csk Kumar
Greenhorn

Joined: Mar 07, 2011
Posts: 13
Hi Johnson,

Thanks for the reply.. Could you please let me know the database and the table details from which i can delete the messages.
I have some basic idea like that Jboss MQ uses HSQL DB for storing messages.
So if possible please suggest me the table and database name details.

Thanks & Regards,
Chethan
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

So are still using HSQLDB for messaging? Are you storing anything else in that database? If not, simply delete the server/default/data directory - that directory contains the persisted database contents used by HSQLDB. So deleting the directory will remove all of the messages.

By the way, I hope that you are not using this system in production - using HSQLDB in production is not recommended because you can lose messages if there is problem (such as a power loss or JVM crash).
Csk Kumar
Greenhorn

Joined: Mar 07, 2011
Posts: 13
Thanks Johnson for your valuable reponse. Now its working fine.

When i deleted the data folder from jboss it gave "java.sql.SQLException: length must be specified in type definition: VARBINARY" exception.
I found the solution from net and I am attaching the same below so that it will be useful for others.

- Open the JBOSS_HOME/server/< servername>/conf/standardjbosscmp-jdbc.xml in a text editor

- Search for the "Hypersonic SQL" type-mappping in that file. It will look something like this:



Try changing it to:



Question: But i did not understand what is VARBINARY and why its changed to 1024.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to Delete Messages from Jboss Queue during jboss shut down?