use of cbit.vcell.message.VCMessagingException in project vcell by virtualcell.
the class SimulationTaskMessage method toMessage.
/**
* Insert the method's description here.
* Creation date: (12/31/2003 11:08:17 AM)
* @return javax.jms.Message
* @param session cbit.vcell.messaging.VCellSession
* @throws VCMessagingException
*/
private VCMessage toMessage(VCMessageSession session) throws VCMessagingException {
VCMessage message;
try {
message = session.createTextMessage(XmlHelper.simTaskToXML(simTask));
} catch (XmlParseException e) {
e.printStackTrace(System.out);
throw new VCMessagingException("failed to restore Simulation Task from XML", e);
}
// must have
message.setStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY, MessageConstants.MESSAGE_TYPE_SIMULATION_JOB_VALUE);
// must have
message.setIntProperty(MessageConstants.JOBINDEX_PROPERTY, simTask.getSimulationJob().getJobIndex());
// must have
message.setIntProperty(MessageConstants.TASKID_PROPERTY, simTask.getTaskID());
// might be used to remove from the job queue when do stopSimulation
message.setStringProperty(VCMessagingConstants.USERNAME_PROPERTY, simTask.getUserName());
// might be used to remove from the job queue when do stopSimulation
message.setLongProperty(MessageConstants.SIMKEY_PROPERTY, Long.parseLong(simTask.getSimKey() + ""));
// for worker message filter
message.setDoubleProperty(MessageConstants.SIZE_MB_PROPERTY, simTask.getEstimatedMemorySizeMB());
if (simTask.getComputeResource() != null) {
// for worker message filter
message.setStringProperty(MessageConstants.COMPUTE_RESOURCE_PROPERTY, simTask.getComputeResource());
}
FieldDataIdentifierSpec[] fieldDataIDs = simTask.getSimulationJob().getFieldDataIdentifierSpecs();
if (fieldDataIDs != null && fieldDataIDs.length > 0) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < fieldDataIDs.length; i++) {
sb.append(fieldDataIDs[i].toCSVString() + "\n");
}
message.setStringProperty(MessageConstants.FIELDDATAID_PROPERTY, sb.toString());
}
return message;
}
use of cbit.vcell.message.VCMessagingException in project vcell by virtualcell.
the class ClientTopicMessageCollector method onTopicMessage.
/**
* Insert the method's description here.
* Creation date: (10/23/2001 3:58:52 PM)
* @param message javax.jms.Message
* @throws VCMessagingException
*/
public void onTopicMessage(VCMessage message, VCMessageSession session) {
if (message == null) {
return;
}
try {
if (message.getObjectContent() == null) {
throw new Exception(this.getClass().getName() + ".onTopicMessage: unimplemented message class " + message.show());
}
setTimeSinceLastMessage(System.currentTimeMillis());
String msgType = message.getStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY);
if (msgType == null) {
throw new Exception(this.getClass().getName() + ".onTopicMessage: message type NULL for message " + message);
}
if (msgType.equals(MessageConstants.MESSAGE_TYPE_SIMSTATUS_VALUE)) {
String messageUserName = message.getStringProperty(VCMessagingConstants.USERNAME_PROPERTY);
StatusMessage statusMessage = new StatusMessage(message);
String userName = VCMessagingConstants.USERNAME_PROPERTY_VALUE_ALL;
if (message.propertyExists(VCMessagingConstants.USERNAME_PROPERTY)) {
userName = message.getStringProperty(VCMessagingConstants.USERNAME_PROPERTY);
}
SimulationJobStatus newJobStatus = statusMessage.getJobStatus();
if (newJobStatus == null) {
return;
}
VCSimulationIdentifier vcSimID = newJobStatus.getVCSimulationIdentifier();
Double progress = statusMessage.getProgress();
Double timePoint = statusMessage.getTimePoint();
fireSimulationJobStatusEvent(new SimulationJobStatusEvent(this, vcSimID.getID(), newJobStatus, progress, timePoint, messageUserName));
} else if (msgType.equals(MessageConstants.MESSAGE_TYPE_EXPORT_EVENT_VALUE)) {
String messageUserName = message.getStringProperty(VCMessagingConstants.USERNAME_PROPERTY);
ExportEvent event = (ExportEvent) message.getObjectContent();
fireExportEvent(event);
} else if (msgType.equals(MessageConstants.MESSAGE_TYPE_DATA_EVENT_VALUE)) {
String messageUserName = message.getStringProperty(VCMessagingConstants.USERNAME_PROPERTY);
DataJobEvent event = (DataJobEvent) message.getObjectContent();
fireMessageEvent(event);
} else if (msgType.equals(MessageConstants.MESSAGE_TYPE_BROADCASTMESSAGE_VALUE)) {
String messageUserName = message.getStringProperty(VCMessagingConstants.USERNAME_PROPERTY);
fireMessageEvent(new VCellMessageEvent(this, System.currentTimeMillis() + "", new MessageData((BigString) message.getObjectContent()), VCellMessageEvent.VCELL_MESSAGEEVENT_TYPE_BROADCAST, messageUserName));
} else {
throw new Exception(this.getClass().getName() + ".onControlTopicMessage: Unimplemented message " + message.show());
}
} catch (Exception e) {
e.printStackTrace();
lg.error(e.getMessage(), e);
}
}
use of cbit.vcell.message.VCMessagingException in project vcell by virtualcell.
the class ConsumerContextJms method init.
public void init() throws JMSException {
boolean bTransacted = true;
int acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
try {
this.jmsConnection = vcMessagingServiceJms.createConnectionFactory().createConnection();
this.jmsConnection.setExceptionListener(new ExceptionListener() {
public void onException(JMSException arg0) {
ConsumerContextJms.this.onException(arg0);
}
});
this.jmsConnection.start();
this.jmsSession = this.jmsConnection.createSession(bTransacted, acknowledgeMode);
this.jmsMessageConsumer = this.vcMessagingServiceJms.createConsumer(this.jmsSession, vcConsumer.getVCDestination(), vcConsumer.getSelector(), vcConsumer.getPrefetchLimit());
} catch (JMSException | VCMessagingException e) {
e.printStackTrace(System.out);
onException(e);
}
}
use of cbit.vcell.message.VCMessagingException in project vcell by virtualcell.
the class VCellServices method dataJobMessage.
public void dataJobMessage(cbit.rmi.event.DataJobEvent event) {
synchronized (dataSession) {
try {
// VCMessageSession dataSession = vcMessagingService.createProducerSession();
VCMessage dataEventMessage = dataSession.createObjectMessage(event);
dataEventMessage.setStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY, MessageConstants.MESSAGE_TYPE_DATA_EVENT_VALUE);
dataEventMessage.setStringProperty(VCMessagingConstants.USERNAME_PROPERTY, event.getUser().getName());
dataSession.sendTopicMessage(VCellTopic.ClientStatusTopic, dataEventMessage);
// dataSession.close();
} catch (VCMessagingException ex) {
lg.error(ex.getMessage(), ex);
}
}
}
use of cbit.vcell.message.VCMessagingException in project vcell by virtualcell.
the class VCellServices method exportMessage.
public void exportMessage(cbit.rmi.event.ExportEvent event) {
synchronized (exportSession) {
try {
// VCMessageSession dataSession = vcMessagingService.createProducerSession();
VCMessage exportEventMessage = exportSession.createObjectMessage(event);
exportEventMessage.setStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY, MessageConstants.MESSAGE_TYPE_EXPORT_EVENT_VALUE);
exportEventMessage.setStringProperty(VCMessagingConstants.USERNAME_PROPERTY, event.getUser().getName());
exportSession.sendTopicMessage(VCellTopic.ClientStatusTopic, exportEventMessage);
// dataSession.close();
} catch (VCMessagingException ex) {
lg.error(ex.getMessage(), ex);
}
}
}
Aggregations