// JMSCommunicationThread
 @Override
 protected void closeProducersAndConsumers() throws Exception {
   timeout_timer.cancel();
   server_consumer.close();
   server_consumer = null;
   client_consumer.close();
   client_consumer = null;
   if (client_producer != null) {
     client_producer.close();
     client_producer = null;
   }
 }
  /** Invoked for received messages */
  private void handleMapMessage(final MapMessage message) {
    try {
      final String text = message.getString(JMSLogMessage.TEXT);
      Runnable action = null;

      // Create action, or handle the message right away

      // Alarm state change?
      if (JMSAlarmMessage.TEXT_STATE.equals(text)) {
        // Received a state update from server, reset timeout
        timeout_timer.reset();
        action = new UpdateAction(AlarmUpdateInfo.fromMapMessage(message));
        model.updateServerState(false);
      } else if (JMSAlarmMessage.TEXT_STATE_MAINTENANCE.equals(text)) {
        timeout_timer.reset();
        action = new UpdateAction(AlarmUpdateInfo.fromMapMessage(message));
        model.updateServerState(true);
      }
      // Idle messages in absence of 'real' traffic?
      else if (JMSAlarmMessage.TEXT_IDLE.equals(text)) {
        timeout_timer.reset();
        model.updateServerState(false);
      } else if (JMSAlarmMessage.TEXT_IDLE_MAINTENANCE.equals(text)) {
        timeout_timer.reset();
        model.updateServerState(true);
      }
      // Enable/disable?
      else if (JMSAlarmMessage.TEXT_ENABLE.equals(text)) {
        timeout_timer.reset();
        final String name = message.getString(JMSLogMessage.NAME);
        action = new EnableAction(name, true);
      } else if (JMSAlarmMessage.TEXT_DISABLE.equals(text)) {
        timeout_timer.reset();
        final String name = message.getString(JMSLogMessage.NAME);
        action = new EnableAction(name, false);
      }
      // Configuration change
      else if (JMSAlarmMessage.TEXT_CONFIG.equals(text)) {
        final String name = message.getString(JMSLogMessage.NAME);
        model.readConfig(name);
      }
      // Debug trigger
      else if (JMSAlarmMessage.TEXT_DEBUG.equals(text)) model.dump();

      if (action == null) return;
      // Queue or dispatch?
      synchronized (queue) {
        if (use_queue) {
          queue.execute(action);
          return;
        }
      }
      // else: Not using queue, and queue no longer locked
      action.run();
    } catch (Throwable ex) {
      Activator.getLogger().log(Level.SEVERE, "Message handler error", ex);
    }
  }
 /**
  * Initialize communicator that writes to the 'client' topic and listens to 'server' topic
  *
  * @param model Model for which to communicate
  * @throws Exception on error
  */
 public AlarmClientCommunicator(final AlarmClientModel model) throws Exception {
   super(Preferences.getJMS_URL());
   this.model = model;
   timeout_timer.start();
 }