Search in sources :

Example 1 with VCMessagingException

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;
}
Also used : VCMessage(cbit.vcell.message.VCMessage) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) XmlParseException(cbit.vcell.xml.XmlParseException) VCMessagingException(cbit.vcell.message.VCMessagingException)

Example 2 with VCMessagingException

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);
    }
}
Also used : DataJobEvent(cbit.rmi.event.DataJobEvent) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) ExportEvent(cbit.rmi.event.ExportEvent) MessageData(cbit.rmi.event.MessageData) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) VCellMessageEvent(cbit.rmi.event.VCellMessageEvent) BigString(org.vcell.util.BigString) SimulationJobStatusEvent(cbit.rmi.event.SimulationJobStatusEvent) BigString(org.vcell.util.BigString) VCMessagingException(cbit.vcell.message.VCMessagingException) StatusMessage(cbit.vcell.message.messages.StatusMessage)

Example 3 with VCMessagingException

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);
    }
}
Also used : ExceptionListener(javax.jms.ExceptionListener) JMSException(javax.jms.JMSException) VCMessagingException(cbit.vcell.message.VCMessagingException)

Example 4 with VCMessagingException

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);
        }
    }
}
Also used : VCMessage(cbit.vcell.message.VCMessage) VCMessagingException(cbit.vcell.message.VCMessagingException)

Example 5 with VCMessagingException

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);
        }
    }
}
Also used : VCMessage(cbit.vcell.message.VCMessage) VCMessagingException(cbit.vcell.message.VCMessagingException)

Aggregations

VCMessagingException (cbit.vcell.message.VCMessagingException)15 VCMessage (cbit.vcell.message.VCMessage)7 VCMessageSession (cbit.vcell.message.VCMessageSession)6 VCMessagingService (cbit.vcell.message.VCMessagingService)4 ServerMessagingDelegate (cbit.vcell.message.server.ServerMessagingDelegate)3 JMSException (javax.jms.JMSException)3 VCMessagingInvocationTargetException (cbit.vcell.message.VCMessagingInvocationTargetException)2 VCPooledQueueConsumer (cbit.vcell.message.VCPooledQueueConsumer)2 VCQueueConsumer (cbit.vcell.message.VCQueueConsumer)2 VCellServiceMXBeanImpl (cbit.vcell.message.server.jmx.VCellServiceMXBeanImpl)2 SimulationTask (cbit.vcell.messaging.server.SimulationTask)2 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)2 XmlParseException (cbit.vcell.xml.XmlParseException)2 FileNotFoundException (java.io.FileNotFoundException)2 MBeanServer (javax.management.MBeanServer)2 ObjectName (javax.management.ObjectName)2 DataJobEvent (cbit.rmi.event.DataJobEvent)1 ExportEvent (cbit.rmi.event.ExportEvent)1 MessageData (cbit.rmi.event.MessageData)1 SimulationJobStatusEvent (cbit.rmi.event.SimulationJobStatusEvent)1