You can get a 100% portable standalone JMS application with essentially no extra work on your part if the JMS providers you're switching between also provide a JNDI implementation. The JMS specification doesn't require JNDI but it establishes the convention that JNDI be used to locate administered objects like connections factories and destinations so it is very common for JMS providers to also provide a JNDI implementation as well.
In short your application can simply use the JMS and JNDI APIs. JMS and JNDI implementation details can be isolated to a jndi.properties
file placed on the application's classpath. Switching between providers would be as simple as changing this properties file and changing the jars on the classpath.
If the JMS providers you're switching between don't provide JNDI implementations then you'll have to use implementation-specific code to create your connection factories and destinations. This will, of course, hurt portability, but you should be able to create your own API to isolate these details to classes which you can switch out for yourself.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…