Search in sources :

Example 26 with MessageProcessor

use of org.opensmartgridplatform.shared.infra.jms.MessageProcessor in project open-smart-grid-platform by OSGP.

the class OsgpCoreResponseMessageListener method onMessage.

@Override
public void onMessage(final Message message) {
    try {
        LOGGER.info("Received message of type: {}", message.getJMSType());
        final ObjectMessage objectMessage = (ObjectMessage) message;
        final MessageProcessor processor = this.messageProcessorMap.getMessageProcessor(objectMessage);
        processor.processMessage(objectMessage);
    } catch (final JMSException ex) {
        LOGGER.error("Exception: {} ", ex.getMessage(), ex);
    }
}
Also used : ObjectMessage(javax.jms.ObjectMessage) MessageProcessor(org.opensmartgridplatform.shared.infra.jms.MessageProcessor) JMSException(javax.jms.JMSException)

Example 27 with MessageProcessor

use of org.opensmartgridplatform.shared.infra.jms.MessageProcessor in project open-smart-grid-platform by OSGP.

the class ProtocolRequestMessageListener method onMessage.

@Override
public void onMessage(final Message message) {
    try {
        LOGGER.info("Received message of type: {}", message.getJMSType());
        final ObjectMessage objectMessage = (ObjectMessage) message;
        // message processor.
        try {
            final MessageProcessor processor = this.protocolRequestMessageProcessorMap.getMessageProcessor(objectMessage);
            processor.processMessage(objectMessage);
        } catch (final JMSException ex) {
            LOGGER.error("JMSException", ex);
            // The message needs to be sent to a domain adapter.
            this.sendMessageToDomainAdapter((RequestMessage) objectMessage.getObject(), message.getJMSType());
        }
    } catch (final JMSException e) {
        LOGGER.error("Exception: {}, StackTrace: {}", e.getMessage(), e.getStackTrace(), e);
    }
}
Also used : ObjectMessage(javax.jms.ObjectMessage) MessageProcessor(org.opensmartgridplatform.shared.infra.jms.MessageProcessor) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) JMSException(javax.jms.JMSException)

Example 28 with MessageProcessor

use of org.opensmartgridplatform.shared.infra.jms.MessageProcessor in project open-smart-grid-platform by OSGP.

the class DeviceRequestMessageListener method onMessage.

@Override
public void onMessage(final Message message) {
    final ObjectMessage objectMessage = (ObjectMessage) message;
    String correlationUid = null;
    String messageType = null;
    final int messagePriority;
    try {
        correlationUid = message.getJMSCorrelationID();
        messageType = message.getJMSType();
        messagePriority = message.getJMSPriority();
        LOGGER.info("Received message [correlationUid={}, messageType={}, messagePriority={}]", correlationUid, messageType, messagePriority);
        final MessageProcessor processor = this.iec61850RequestMessageProcessorMap.getMessageProcessor(objectMessage);
        processor.processMessage(objectMessage);
    } catch (final IllegalArgumentException | JMSException e) {
        LOGGER.error("Unexpected exception for message [correlationUid={}]", correlationUid, e);
        this.createAndSendException(objectMessage, messageType);
    }
}
Also used : ObjectMessage(javax.jms.ObjectMessage) MessageProcessor(org.opensmartgridplatform.shared.infra.jms.MessageProcessor) JMSException(javax.jms.JMSException)

Aggregations

ObjectMessage (javax.jms.ObjectMessage)28 MessageProcessor (org.opensmartgridplatform.shared.infra.jms.MessageProcessor)28 JMSException (javax.jms.JMSException)26 NotSupportedException (org.opensmartgridplatform.shared.exceptionhandling.NotSupportedException)2 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)2 Test (org.junit.jupiter.api.Test)1 GetHealthStatusRequestMessageProcessor (org.opensmartgridplatform.adapter.protocol.iec60870.infra.messaging.processors.GetHealthStatusRequestMessageProcessor)1 GetHealthStatusRequestDto (org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 MessageType (org.opensmartgridplatform.shared.infra.jms.MessageType)1 ObjectMessageBuilder (org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder)1 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)1