Search in sources :

Example 1 with MessagePropertyNotFoundException

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);
}
Also used : TopicListener(cbit.vcell.message.VCTopicConsumer.TopicListener) KeyValue(org.vcell.util.document.KeyValue) MessagePropertyNotFoundException(cbit.vcell.message.MessagePropertyNotFoundException) VCMessageSelector(cbit.vcell.message.VCMessageSelector) VCMessage(cbit.vcell.message.VCMessage) VCTopicConsumer(cbit.vcell.message.VCTopicConsumer) VCMessageSession(cbit.vcell.message.VCMessageSession) VCellTopic(cbit.vcell.message.VCellTopic)

Example 2 with MessagePropertyNotFoundException

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);
}
Also used : TopicListener(cbit.vcell.message.VCTopicConsumer.TopicListener) KeyValue(org.vcell.util.document.KeyValue) MessagePropertyNotFoundException(cbit.vcell.message.MessagePropertyNotFoundException) VCMessageSelector(cbit.vcell.message.VCMessageSelector) VCMessage(cbit.vcell.message.VCMessage) VCTopicConsumer(cbit.vcell.message.VCTopicConsumer) VCMessageSession(cbit.vcell.message.VCMessageSession) VCellTopic(cbit.vcell.message.VCellTopic)

Example 3 with MessagePropertyNotFoundException

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();
}
Also used : MessagePropertyNotFoundException(cbit.vcell.message.MessagePropertyNotFoundException) Enumeration(java.util.Enumeration) ObjectMessage(javax.jms.ObjectMessage) JMSException(javax.jms.JMSException) TextMessage(javax.jms.TextMessage)

Example 4 with MessagePropertyNotFoundException

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();
}
Also used : MessagePropertyNotFoundException(cbit.vcell.message.MessagePropertyNotFoundException) Enumeration(java.util.Enumeration)

Aggregations

MessagePropertyNotFoundException (cbit.vcell.message.MessagePropertyNotFoundException)4 VCMessage (cbit.vcell.message.VCMessage)2 VCMessageSelector (cbit.vcell.message.VCMessageSelector)2 VCMessageSession (cbit.vcell.message.VCMessageSession)2 VCTopicConsumer (cbit.vcell.message.VCTopicConsumer)2 TopicListener (cbit.vcell.message.VCTopicConsumer.TopicListener)2 VCellTopic (cbit.vcell.message.VCellTopic)2 Enumeration (java.util.Enumeration)2 KeyValue (org.vcell.util.document.KeyValue)2 JMSException (javax.jms.JMSException)1 ObjectMessage (javax.jms.ObjectMessage)1 TextMessage (javax.jms.TextMessage)1