Search in sources :

Example 6 with ACSJMSTextMessage

use of com.cosylab.acs.jms.ACSJMSTextMessage in project ACS by ACS-Community.

the class AlarmSelectionHelper method onMessage.

//
// -- implements SubscriptionListener ---------------------------------
//
/**
   * DOCUMENT ME!
   * 
   * @param msg DOCUMENT ME!
   */
public void onMessage(Message msg) {
    ACSJMSTextMessage acsMsg = (ACSJMSTextMessage) msg;
    if (selectionListener != null) {
        try {
            cern.laser.business.data.AlarmImpl business_alarm = AlarmMessageConversion.getAlarm(((ACSJMSTextMessage) msg).getText());
            AlarmImpl alarm = new AlarmImpl(business_alarm);
            selectionListener.onAlarm(alarm);
        } catch (Exception e) {
            LOGGER.warn("error on message", e);
        }
    }
}
Also used : AlarmImpl(cern.laser.client.impl.data.AlarmImpl) ACSJMSTextMessage(com.cosylab.acs.jms.ACSJMSTextMessage) LaserConnectionException(cern.laser.client.LaserConnectionException) LaserException(cern.laser.client.LaserException) UnknownHostException(java.net.UnknownHostException) JMSException(javax.jms.JMSException) MOMException(cern.cmw.mom.pubsub.MOMException) LaserSelectionException(cern.laser.client.services.selection.LaserSelectionException) LaserTimeOutException(cern.laser.client.LaserTimeOutException)

Example 7 with ACSJMSTextMessage

use of com.cosylab.acs.jms.ACSJMSTextMessage in project ACS by ACS-Community.

the class LaserCoreFaultState method createJMSMessage.

/**
	 * Create an acs text jms message containing the passed
	 * fault state in form of XML (ASIMessage) in the body.
	 *  
	 * @param fs The <code>FaultState</code> to set in the message
	 * @param cs The <code>ContainerServicesBase</code>
	 * @return The jms text message containing the fault state
	 */
public static ACSJMSTextMessage createJMSMessage(FaultState fs, ContainerServicesBase cs) throws Exception {
    if (fs == null) {
        throw new IllegalArgumentException("The fault state can't be null");
    }
    if (cs == null) {
        throw new IllegalArgumentException("The container services can't be null");
    }
    Vector<FaultState> states = new Vector<FaultState>();
    states.add(fs);
    ASIMessage asiMessage = ASIMessageHelper.marshal(states);
    // Set the timestamp
    String sourceTimestamp = IsoDateFormat.formatCurrentDate();
    asiMessage.setSourceTimestamp(sourceTimestamp);
    // Set the hostname
    if (hostName == null) {
        InetAddress iAddr = InetAddress.getLocalHost();
        hostName = iAddr.getHostName();
    }
    asiMessage.setSourceHostname(hostName);
    asiMessage.setSourceName("ALARM_SYSTEM_SOURCES");
    ACSJMSTextMessage textMessage = new ACSJMSTextMessage(cs);
    textMessage.setText(XMLMessageHelper.marshal(asiMessage));
    return textMessage;
}
Also used : FaultState(cern.laser.source.alarmsysteminterface.FaultState) ACSJMSTextMessage(com.cosylab.acs.jms.ACSJMSTextMessage) Vector(java.util.Vector) InetAddress(java.net.InetAddress) ASIMessage(cern.laser.source.alarmsysteminterface.impl.message.ASIMessage)

Example 8 with ACSJMSTextMessage

use of com.cosylab.acs.jms.ACSJMSTextMessage in project ACS by ACS-Community.

the class CategorySubscriber method onMessage.

/**
	 * Executed when a message has been received
	 * 
	 * @param msg
	 */
public void onMessage(Message msg) {
    if (closed) {
        return;
    }
    acsCS.getLogger().log(AcsLogLevel.DEBUG, "Message received from " + rootName + "." + pathName);
    if (msg instanceof ACSJMSTextMessage) {
        ACSJMSTextMessage textMsg = (ACSJMSTextMessage) msg;
        String content = null;
        try {
            content = textMsg.getText();
        } catch (JMSException e) {
            acsCS.getLogger().log(AcsLogLevel.WARNING, "Exception caught while getting a message " + e.getMessage());
            return;
        }
        if (content == null || content.length() == 0) {
            return;
        }
        adddAlarmView(content);
    } else {
        System.out.println("Not a text msg");
    }
}
Also used : ACSJMSTextMessage(com.cosylab.acs.jms.ACSJMSTextMessage) JMSException(javax.jms.JMSException)

Aggregations

ACSJMSTextMessage (com.cosylab.acs.jms.ACSJMSTextMessage)8 ASIMessage (cern.laser.source.alarmsysteminterface.impl.message.ASIMessage)4 FaultState (cern.laser.source.alarmsysteminterface.FaultState)3 FaultStateImpl (cern.laser.source.alarmsysteminterface.impl.FaultStateImpl)3 Vector (java.util.Vector)3 LaserCoreFaultState (alma.alarmsystem.core.alarms.LaserCoreFaultState)2 Timestamp (java.sql.Timestamp)2 JMSException (javax.jms.JMSException)2 ContainerServices (alma.acs.container.ContainerServices)1 DummyContainerServices (alma.acs.container.testsupport.DummyContainerServices)1 ACSFaultState (alma.alarmsystem.source.ACSFaultState)1 MOMException (cern.cmw.mom.pubsub.MOMException)1 LaserConnectionException (cern.laser.client.LaserConnectionException)1 LaserException (cern.laser.client.LaserException)1 LaserTimeOutException (cern.laser.client.LaserTimeOutException)1 AlarmImpl (cern.laser.client.impl.data.AlarmImpl)1 LaserSelectionException (cern.laser.client.services.selection.LaserSelectionException)1 Configurator (cern.laser.source.alarmsysteminterface.impl.Configurator)1 ASIConfiguration (cern.laser.source.alarmsysteminterface.impl.configuration.ASIConfiguration)1 FaultState (cern.laser.source.alarmsysteminterface.impl.message.FaultState)1