class JMSCore {

    public void sendJMSMessage(ExtensionServiceMessage message) {
        Map<String, ?> request = (Map<String, ?>) message.getObject();
        Map<String, Object> messageMap = new LinkedHashMap<String, Object>();
        
        // Get local copy of JMS
        JMS localJMS;
        synchronized (SYNCH_LOCK) {
            localJMS = jms;
        }
        
        // Make sure JMS is safe to use (has not been closed)
        if (localJMS == null) {
            log.error("JMS connection closed before operation could complete");
        } else {
            Map headers = null;
            Map properties = null;
            Object msg = null;
            String dest;
            boolean isQueue;
            
            // Getting the contents of the message if specified, or defaulting to an empty string
            if (request.get("message") instanceof String) {
                msg = (String) request.get("message");
            } else if (request.get("message") instanceof Map) {
                msg = (Map) request.get("message");
            } else {
                log.debug("No message was specified in the publish request, or the message was not a String/Map. "
                        + "The message was set to its default value, null.");
            }
                
            // Getting the destination of the message
            if (request.get("queue") instanceof String) {
                dest = (String) request.get("queue");
                isQueue = true;
            } else if (request.get("topic") instanceof String) {
                dest = (String) request.get("topic");
                isQueue = false;
            } else {
                log.error("No destination was specified, or destination was not a String. Either a topic "
                        + "or a queue must be included as a String in the publish request.");
                return;
            }
                        
            // Getting the message headers if specified
            if (request.get("headers") instanceof Map) {
                headers = (Map) request.get("headers");
            }
            
            // Getting the message properties if specified
            if (request.get("properties") instanceof Map) {
                properties = (Map) request.get("properties");
            }
            
            messageMap.put("message", msg);
            messageMap.put("headers", headers);
            messageMap.put("properties", properties);
            
            // Sending the message to the appropriate destination
            try {
                localJMS.produceMessage(messageMap, dest, isQueue);
            } catch (JMSException e) {
                log.error("An error occured when attempting to send the given message.", e);
            } catch (DestinationNotConfiguredException e) {
                log.error("An error occured when attempting to send the given message. The source was not configured "
                        + "to send messages to the following destination: " + dest + ".", e);
            } catch(UnsupportedJMSMessageTypeException e) {
                log.error("An error occured when attempting to send the given message. The provided JMS Message Type: "
                        + e.getMessage() + " is either invalid or not currently supported.");
            } catch (Exception e) {
                log.error("An unexpected error occured when attempting to send the given message.", e);
            }
        }
    }

    public  JMSCore(String sourceName, String authToken, String targetVantiqServer);

}