use of cbit.vcell.message.VCellTopic 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.VCellTopic 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);
}
Aggregations