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);
}
}
}
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;
}
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");
}
}
Aggregations