A good JMS provider will support auto-reconnection for you.
e.g. ActiveMQ supports this feature...
http://activemq.org/
to auto-reconnect, add 'reliable:' to the beginning of the URL you use to connect to the JMS broker. e.g. use
reliable:tcp://host1:port,tcp://host2:port
to have a reliable connection to a cluster of 2 brokers
BTW, SJS MQ (The MQ with the J2EE Reference Implementation) also supports that.
If you are using a queue, you should not loose messages. This is what the JMS spec is all about. If you are using a topic (message broadcast) then you would need to set the client as a durable subscriber, this way, if the client is not connected, the messages are kept for him to come back.
Another point, if the connection is lost because the message broker went down, then all messages that were not consumed on that destination are lost, if they were not persisted.
If the messages are persisted then you should have all the messages still available when you restart the broker and reconnect to it. Now since brokers try to be smart about persisting and minimise the disk I/O, you need to learn how the persistence of your broker works, and make sure you configure it to the performance/reliability balance you require for your application.
TE