use of javax.jms.TextMessage in project ACS by ACS-Community.
the class AlarmPublisherImpl method sendInit.
public void sendInit(Collection alarms, String destination) {
try {
logger.log(AcsLogLevel.DEBUG, "sending " + alarms.size() + " initial alarm(s) to " + destination + "...");
Topic topic = getTopicSession().createTopic(destination);
TextMessage message = getTopicSession().createTextMessage();
Iterator iterator = alarms.iterator();
while (iterator.hasNext()) {
AlarmImpl alarm = (AlarmImpl) iterator.next();
message.setText(AlarmMessageConversion.getXML(alarm));
message.clearProperties();
setMessageProperties(message, alarm);
message.setObjectProperty("NOT_REDUCED_MASKED_SET", Boolean.TRUE);
if (!(alarm.getStatus().getMasked().booleanValue() || alarm.getStatus().getReduced().booleanValue())) {
message.setObjectProperty("REDUCED_MASKED_SET", Boolean.TRUE);
} else {
message.setObjectProperty("REDUCED_MASKED_SET", Boolean.FALSE);
}
getTopicPublisher().publish(topic, message);
}
logger.log(AcsLogLevel.DEBUG, "initial alarm(s) sent to " + destination);
} catch (Exception e) {
close();
throw new LaserRuntimeException("unable to send alarms to " + destination + " : " + e.getMessage());
}
}
use of javax.jms.TextMessage in project ACS by ACS-Community.
the class AlarmPublisherImpl method sendInit.
public void sendInit(AlarmImpl alarm, String destination) {
try {
Topic topic = getTopicSession().createTopic(destination);
TextMessage message = getTopicSession().createTextMessage();
message.setText(AlarmMessageConversion.getXML(alarm));
setMessageProperties(message, alarm);
message.setObjectProperty("NOT_REDUCED_MASKED_SET", Boolean.TRUE);
if (!(alarm.getStatus().getMasked().booleanValue() || alarm.getStatus().getReduced().booleanValue())) {
message.setObjectProperty("REDUCED_MASKED_SET", Boolean.TRUE);
} else {
message.setObjectProperty("REDUCED_MASKED_SET", Boolean.FALSE);
}
getTopicPublisher().publish(topic, message);
} catch (Exception e) {
logger.log(AcsLogLevel.ERROR, "unable to send alarm " + alarm.getAlarmId() + " to destination " + destination, e);
close();
//throw new EJBException("unable to send alarm " + alarm.getAlarmId() + " to destination " + destination, e);
}
}
use of javax.jms.TextMessage in project ACS by ACS-Community.
the class AlarmMessageProcessorImpl method process.
public void process(Message alarmMessage) throws Exception {
if (alarmMessage instanceof TextMessage) {
TextMessage text_message = (TextMessage) alarmMessage;
}
logger.log(AcsLogLevel.DEBUG, "processing message...", true);
if (alarmMessage instanceof TextMessage) {
TextMessage text_message = (TextMessage) alarmMessage;
String xml_message = text_message.getText();
process(xml_message);
} else {
throw new Exception("TextMessage expected");
}
logger.log(AcsLogLevel.DEBUG, "message processed");
}
use of javax.jms.TextMessage in project ACS by ACS-Community.
the class ASISubscriptionListener method onMessage.
/**
* Callback method implementation.
* @param message the JMS message received.
*/
public void onMessage(Message message) {
cat.debug("got a message");
if (message instanceof TextMessage) {
try {
TextMessage text_message = (TextMessage) message;
String xml_message = text_message.getText();
ASIMessage asi_message = XMLMessageHelper.unmarshal(xml_message);
String source_name = asi_message.getSourceName();
String source_hostname = asi_message.getSourceHostname();
boolean backup = asi_message.getBackup();
// ISO format
String source_timestamp = asi_message.getSourceTimestamp();
Collection states = ASIMessageHelper.unmarshal(asi_message);
listener.onMessage(source_name, source_hostname, source_timestamp, backup, states);
} catch (Exception e) {
cat.error("exception caught : " + e.getMessage(), e);
}
}
}
use of javax.jms.TextMessage in project javaee7-samples by javaee-samples.
the class MessageReceiverAsync method onMessage.
@Override
public void onMessage(Message message) {
try {
TextMessage tm = (TextMessage) message;
System.out.println("Message received (async): " + tm.getText());
} catch (JMSException ex) {
Logger.getLogger(MessageReceiverAsync.class.getName()).log(Level.SEVERE, null, ex);
}
}
Aggregations