use of cbit.vcell.message.MessagePropertyNotFoundException in project vcell by virtualcell.
the class JavaSimulationExecutable method init.
protected void init() throws JMSException {
//
// session used for sending worker events.
//
this.workerEventSession = vcMessagingService.createProducerSession();
//
// message consumer for Service Control topic message (to stop simulation).
//
VCellTopic topic = VCellTopic.ServiceControlTopic;
TopicListener listener = new TopicListener() {
public void onTopicMessage(VCMessage vcMessage, VCMessageSession session) {
if (lg.isTraceEnabled())
lg.trace("JavaSimulationExecutable::onControlTopicMessage(): " + vcMessage.show());
try {
String msgType = vcMessage.getStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY);
if (msgType != null && msgType.equals(MessageConstants.MESSAGE_TYPE_STOPSIMULATION_VALUE)) {
Long longkey = vcMessage.getLongProperty(MessageConstants.SIMKEY_PROPERTY);
KeyValue simKey = new KeyValue(longkey + "");
int jobIndex = vcMessage.getIntProperty(MessageConstants.JOBINDEX_PROPERTY);
if (simKey.equals(simulationTask.getSimKey()) && jobIndex == simulationTask.getSimulationJob().getJobIndex()) {
solver.stopSolver();
}
}
} catch (MessagePropertyNotFoundException ex) {
lg.error(ex.getMessage(), ex);
return;
}
}
};
VCMessageSelector selector = null;
String threadName = "Service Control Topic Consumer";
VCTopicConsumer serviceControlConsumer = new VCTopicConsumer(topic, listener, selector, threadName, MessageConstants.PREFETCH_LIMIT_SERVICE_CONTROL);
vcMessagingService.addMessageConsumer(serviceControlConsumer);
}
use of cbit.vcell.message.MessagePropertyNotFoundException in project vcell by virtualcell.
the class JavaSimulationExecutable method init.
protected void init() throws JMSException {
//
// session used for sending worker events.
//
this.workerEventSession = vcMessagingService.createProducerSession();
//
// message consumer for Service Control topic message (to stop simulation).
//
VCellTopic topic = VCellTopic.ServiceControlTopic;
TopicListener listener = new TopicListener() {
public void onTopicMessage(VCMessage vcMessage, VCMessageSession session) {
if (lg.isTraceEnabled())
lg.trace("JavaSimulationExecutable::onControlTopicMessage(): " + vcMessage.show());
try {
String msgType = vcMessage.getStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY);
if (msgType != null && msgType.equals(MessageConstants.MESSAGE_TYPE_STOPSIMULATION_VALUE)) {
Long longkey = vcMessage.getLongProperty(MessageConstants.SIMKEY_PROPERTY);
KeyValue simKey = new KeyValue(longkey + "");
int jobIndex = vcMessage.getIntProperty(MessageConstants.JOBINDEX_PROPERTY);
if (simKey.equals(simulationTask.getSimKey()) && jobIndex == simulationTask.getSimulationJob().getJobIndex()) {
solver.stopSolver();
}
}
} catch (MessagePropertyNotFoundException ex) {
lg.error(ex.getMessage(), ex);
return;
}
}
};
VCMessageSelector selector = null;
String threadName = "Service Control Topic Consumer";
VCTopicConsumer serviceControlConsumer = new VCTopicConsumer(topic, listener, selector, threadName, MessageConstants.PREFETCH_LIMIT_SERVICE_CONTROL);
vcMessagingService.addMessageConsumer(serviceControlConsumer);
}
use of cbit.vcell.message.MessagePropertyNotFoundException in project vcell by virtualcell.
the class VCMessageJms method show.
public String show() {
StringBuffer buffer = new StringBuffer();
try {
java.util.Enumeration enum1 = jmsMessage.getPropertyNames();
while (enum1.hasMoreElements()) {
String propName = (String) enum1.nextElement();
try {
String value = jmsMessage.getStringProperty(propName);
buffer.append(" " + propName + "='" + value + "'");
} catch (MessagePropertyNotFoundException ex) {
// definitely should not happen
delegate.onException(ex);
}
}
int maxContentLength = 120;
if (jmsMessage instanceof TextMessage) {
buffer.append(" textContent='");
String textContent = ((TextMessage) jmsMessage).getText();
if (textContent != null && textContent.length() > maxContentLength) {
buffer.append(textContent.substring(0, maxContentLength - 3) + "...");
} else {
buffer.append(textContent);
}
buffer.append("'");
} else if (jmsMessage instanceof ObjectMessage) {
buffer.append(" objectContent='");
String text = "" + ((ObjectMessage) jmsMessage).getObject();
if (text.length() > maxContentLength) {
buffer.append(text.substring(0, maxContentLength - 3) + "...");
} else {
buffer.append(text);
}
buffer.append("'");
}
} catch (JMSException e) {
e.printStackTrace(System.out);
throw new RuntimeException(e.getMessage(), e);
}
return buffer.toString();
}
use of cbit.vcell.message.MessagePropertyNotFoundException in project vcell by virtualcell.
the class VCMessageBSON method show.
@Override
public String show() {
StringBuffer buffer = new StringBuffer();
java.util.Enumeration enum1 = getPropertyNames();
while (enum1.hasMoreElements()) {
String propName = (String) enum1.nextElement();
try {
String value = getStringProperty(propName);
buffer.append(" " + propName + "='" + value + "'");
} catch (MessagePropertyNotFoundException ex) {
// definitely should not happen
}
}
int maxContentLength = 120;
if (textContent != null) {
buffer.append(" textContent='");
if (textContent.length() > maxContentLength) {
buffer.append(textContent.substring(0, maxContentLength - 3) + "...");
} else {
buffer.append(textContent);
}
buffer.append("'");
} else if (objectContent != null) {
buffer.append(" objectContent='");
String text = objectContent.toString();
if (text.length() > maxContentLength) {
buffer.append(text.substring(0, maxContentLength - 3) + "...");
} else {
buffer.append(text);
}
buffer.append("'");
}
return buffer.toString();
}
Aggregations