One word answer: MDBs (actually it is a 3 word answer )
You would create a message driven bean and subscribe it using the app server's deployment tools, when the message arrives, the method on you MDB will get invoked.
SJCP, SCBCD, SJCD, SCDJWS, SCEA (Part I)
It would give a normal human mental abilities to rival mine. To think it is just a tiny ad:
Gift giving made easy with the permaculture playing cards