Search in sources :

Example 1 with VCMessageJms

use of cbit.vcell.message.jms.VCMessageJms 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 {
        // Check if it's a broadcast message
        if (message instanceof VCMessageJms) {
            VCMessageJms vcMessageJms = (VCMessageJms) message;
            javax.jms.Message myMessage = vcMessageJms.getJmsMessage();
            if (myMessage instanceof ActiveMQTextMessage) {
                ActiveMQTextMessage myAMQ = (ActiveMQTextMessage) myMessage;
                if (myAMQ.getType().equalsIgnoreCase(MessageConstants.MESSAGE_TYPE_BROADCASTMESSAGE_VALUE)) {
                    fireMessageEvent(new VCellMessageEvent(this, System.currentTimeMillis() + "", new MessageData(myAMQ.getText()), VCellMessageEvent.VCELL_MESSAGEEVENT_TYPE_BROADCAST, null));
                    return;
                }
            }
        }
        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 : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) VCMessageJms(cbit.vcell.message.jms.VCMessageJms) MessageData(cbit.rmi.event.MessageData) ExportEvent(cbit.rmi.event.ExportEvent) BigString(org.vcell.util.BigString) SimulationJobStatusEvent(cbit.rmi.event.SimulationJobStatusEvent) BigString(org.vcell.util.BigString) VCMessagingException(cbit.vcell.message.VCMessagingException) ActiveMQTextMessage(org.apache.activemq.command.ActiveMQTextMessage) StatusMessage(cbit.vcell.message.messages.StatusMessage) DataJobEvent(cbit.rmi.event.DataJobEvent) VCellMessageEvent(cbit.rmi.event.VCellMessageEvent) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus)

Aggregations

DataJobEvent (cbit.rmi.event.DataJobEvent)1 ExportEvent (cbit.rmi.event.ExportEvent)1 MessageData (cbit.rmi.event.MessageData)1 SimulationJobStatusEvent (cbit.rmi.event.SimulationJobStatusEvent)1 VCellMessageEvent (cbit.rmi.event.VCellMessageEvent)1 VCMessagingException (cbit.vcell.message.VCMessagingException)1 VCMessageJms (cbit.vcell.message.jms.VCMessageJms)1 StatusMessage (cbit.vcell.message.messages.StatusMessage)1 SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)1 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)1 ActiveMQTextMessage (org.apache.activemq.command.ActiveMQTextMessage)1 BigString (org.vcell.util.BigString)1