// JMSCommunicationThread @Override protected void createProducersAndConsumers() throws Exception { final String configuration = model.getConfigurationName(); // Write (if allowed) and also read the client topic if (model.isWriteAllowed()) client_producer = createProducer(Preferences.getJMS_AlarmClientTopic(configuration)); else client_producer = null; client_consumer = createConsumer(Preferences.getJMS_AlarmClientTopic(configuration)); // Read messages from server server_consumer = createConsumer(Preferences.getJMS_AlarmServerTopic(configuration)); // Handle MapMessages final MessageListener message_listener = new MessageListener() { @Override public void onMessage(final Message message) { if (message instanceof MapMessage) handleMapMessage((MapMessage) message); else Activator.getLogger() .log(Level.WARNING, "Message type {0} not handled", message.getClass().getName()); } }; client_consumer.setMessageListener(message_listener); server_consumer.setMessageListener(message_listener); }
/** * Create message initialized with basic alarm & application info * * @param text TEXT property * @return MapMessage * @throws Exception on error. */ private MapMessage createMapMessage(final String text) throws Exception { final MapMessage map = createMapMessage(); map.setString(JMSLogMessage.TYPE, JMSAlarmMessage.TYPE_ALARM); map.setString(JMSAlarmMessage.CONFIG, model.getConfigurationName()); map.setString(JMSLogMessage.TEXT, text); map.setString(JMSLogMessage.APPLICATION_ID, APPLICATION); map.setString(JMSLogMessage.HOST, host); User loggedUser = SecurityFacade.getInstance().getCurrentUser(); if (loggedUser == null) // if no user logged in... user = System.getProperty("user.name"); // $NON-NLS-1$ else user = loggedUser.getUsername(); map.setString(JMSLogMessage.USER, user); return map; }