class UDPPublishHandler extends Handler<ExtensionServiceMessage> {

    @Override
    public void handleMessage(ExtensionServiceMessage message) {
        Map receivedMsg = (Map) message.getObject();
        Map sendMsg = new LinkedHashMap<String,Object>();
        byte[] sendBytes = null;

        // Translate the message as requested in the Configuration document
        if (formatLocations != null) {
            sendBytes = getFormattedOutput(receivedMsg);
        }
        else if (csvSource != null) {
            String str = buildCsv(receivedMsg);
            sendBytes = str.getBytes();
        }
        else if (bytesLocation != null) {
            sendBytes = ((String)receivedMsg.get(bytesLocation)).getBytes();
        }
        else if (passingPureMap) {
            sendMsg = receivedMsg;
        }
        else if (passingUnspecified) {
            sendMsg = receivedMsg;
            if (this.transformer != null) {
                this.transformer.transform(receivedMsg, sendMsg, true);
            }
        }
        else if (transformer == null) {
            // This means that no transform was specified and neither were any pass___ parameters in which case
            // the design decision is to send an empty Map, so the UDP server is notified that a Publish was sent
            sendMsg = new LinkedHashMap<String,Object>();
        }
        else {
            this.transformer.transform(receivedMsg, sendMsg, false);
        }

        
        // Turn the message into bytes for a UDP message then send it
        try {
            if (sendBytes == null) {
                log.debug("Sending message to address {} and port {} with contents: {}"
                        , address.getHostAddress(), port, sendMsg);
                sendBytes = writer.writeValueAsBytes(sendMsg);
            }
            else {
                log.debug("Sending message to address {} and port {} with contents: {}"
                        , address.getHostAddress(), port, new String(sendBytes));
            }
            DatagramPacket packet = new DatagramPacket(sendBytes, sendBytes.length, address, port);
            socket.send(packet);
        }
        catch (Exception e) {
            log.warn("Failed trying to translate and send the message.", e);
        }
    }

    public  UDPPublishHandler(Map outgoing, DatagramSocket socket, String sourceName);

}