-
1. Re: Looking for suggestions on how to pause my application if identified that the DB is not available
nickarls Dec 25, 2012 7:11 AM (in response to newway)1 of 1 people found this helpfulHmm, I have no AS around to test this but I would think that a @Singleton or @ApplicationScoped component could hold the flag and perhaps a ModelControllerClient can be used for manipulating the messaging system (and checking the state of the DB). The DB state could also be checked by a scheduled task that would call some ping method and catch any exceptions.
-
2. Re: Looking for suggestions on how to pause my application if identified that the DB is not available
newway Dec 26, 2012 7:46 AM (in response to nickarls)Thanks for the pointers.
I didn't implement it yet - but I did some digging around in the CLI to find the commands to use and came up with the following - just sharing for future reference or if someone think I took the wrong commands:
For the data source:
When the DB is down: /subsystem=datasources/data-source=DefaultDS/:test-connection-in-pool { "outcome" => "failed", "failure-description" => "JBAS010440: failed to invoke operation: JBAS010447: Connection is not valid", "rolled-back" => true } When the DB is up: /subsystem=datasources/data-source=DefaultDS/:test-connection-in-pool { "outcome" => "success", "result" => [true] }
For the queues:
List all the queues: /subsystem=messaging/hornetq-server=default/:read-children-resources(child-type=jms-queue,recursive=false,proxies=false,include-runtime=false,include-defaults=true) Pause a queue: /subsystem=messaging/hornetq-server=default/jms-queue=<queue name>/:pause Resume a queue: /subsystem=messaging/hornetq-server=default/jms-queue=<queue name>/:resume
-
3. Re: Looking for suggestions on how to pause my application if identified that the DB is not available
aristides Dec 26, 2012 6:51 PM (in response to newway)I think that @Singleton look like a good solution, but if you are working with cluster you will have one singleton per instance holding the down flag. Therefore I suggest using infinispan to keep the value indicanting if the system is pause.
The scheduled task as suggested before is a good idea to check for DB restore, you could even make you java run a script to restart the database using something like
Runtime.getRuntime().exec("restart.sh").