Search in sources :

Example 11 with MessageProcessor

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

the class OsgpResponseMessageListener method onMessage.

@Override
public void onMessage(final Message message) {
    try {
        LOGGER.info("[{}] - Received message of type: {}", message.getJMSCorrelationID(), message.getJMSType());
        final MessageMetadata metadata = MessageMetadata.fromMessage(message);
        final ObjectMessage objectMessage = (ObjectMessage) message;
        final MessageProcessor messageProcessor = this.messageProcessorMap.getMessageProcessor(objectMessage);
        if (messageProcessor != null) {
            messageProcessor.processMessage(objectMessage);
        } else {
            LOGGER.error("[{}] - Unknown messagetype {}", metadata.getCorrelationUid(), metadata.getMessageType());
        }
    } catch (final JMSException ex) {
        LOGGER.error("Exception: {} ", ex.getMessage(), ex);
    }
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) ObjectMessage(javax.jms.ObjectMessage) MessageProcessor(org.opensmartgridplatform.shared.infra.jms.MessageProcessor) JMSException(javax.jms.JMSException)

Example 12 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) {
    try {
        LOGGER.info("Received message of type: {}", message.getJMSType());
        final ObjectMessage objectMessage = (ObjectMessage) message;
        final MessageProcessor processor = this.dlmsRequestMessageProcessorMap.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 13 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 messageType = null;
    final int messagePriority;
    try {
        messageType = message.getJMSType();
        messagePriority = message.getJMSPriority();
        LOGGER.info("Received message of type: {} with message priority: {}", messageType, messagePriority);
        final MessageProcessor processor = this.oslpRequestMessageProcessorMap.getMessageProcessor(objectMessage);
        processor.processMessage(objectMessage);
    } catch (final JMSException ex) {
        LOGGER.error("Unexpected JMSException during onMessage(Message)", ex);
        this.sendException(objectMessage, ex, "JMSException while processing message");
    } catch (final IllegalArgumentException e) {
        LOGGER.error("Unexpected IllegalArgumentException during onMessage(Message)", e);
        this.sendException(objectMessage, new NotSupportedException(ComponentType.PROTOCOL_OSLP, messageType), "Unsupported device function: " + messageType);
    }
}
Also used : ObjectMessage(javax.jms.ObjectMessage) MessageProcessor(org.opensmartgridplatform.shared.infra.jms.MessageProcessor) JMSException(javax.jms.JMSException) NotSupportedException(org.opensmartgridplatform.shared.exceptionhandling.NotSupportedException)

Example 14 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.osgpCoreResponseMessageProcessorMap.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 15 with MessageProcessor

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

the class OsgpCoreRequestMessageListener method onMessage.

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

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