use of org.opensmartgridplatform.shared.infra.jms.UnknownMessageTypeException in project open-smart-grid-platform by OSGP.
the class CommonRequestMessageListener method onMessage.
@Override
public void onMessage(final Message message) {
try {
LOGGER.info("Received message of type: {}", message.getJMSType());
final ObjectMessage objectMessage = (ObjectMessage) message;
final String correlationUid = objectMessage.getJMSCorrelationID();
final String messageType = objectMessage.getJMSType();
final String organisationIdentification = objectMessage.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
final String deviceIdentification = objectMessage.getStringProperty(Constants.DEVICE_IDENTIFICATION);
final Serializable dataObject = objectMessage.getObject();
if (MessageType.RELAY_STATUS_UPDATED_EVENTS.name().equals(messageType)) {
this.notificationService.sendNotification(organisationIdentification, deviceIdentification, null, correlationUid, null, NotificationType.DEVICE_UPDATED);
} else {
LOGGER.debug("Unknown message received. MessageType: {}, correlationUID: {}, organisation: {}, deviceIdentification: {}, dataObject: {}", messageType, correlationUid, organisationIdentification, deviceIdentification, dataObject == null ? "null" : dataObject.getClass().getCanonicalName());
throw new UnknownMessageTypeException("Unknown JMSType: " + messageType);
}
} catch (final JMSException ex) {
LOGGER.error("Caught JMSException: {} ", ex, ex);
} catch (final UnknownMessageTypeException e) {
LOGGER.error("Caught UnknownMessageTypeException", e);
}
}
use of org.opensmartgridplatform.shared.infra.jms.UnknownMessageTypeException 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");
final ObjectMessage objectMessage = (ObjectMessage) message;
final String messageType = objectMessage.getJMSType();
final RequestMessage requestMessage = (RequestMessage) objectMessage.getObject();
this.osgpCoreRequestMessageProcessor.processMessage(requestMessage, messageType);
} catch (final JMSException e) {
// Can't read message.
LOGGER.error("Exception: {}, StackTrace: {}", e.getMessage(), e.getStackTrace(), e);
} catch (final UnknownMessageTypeException e) {
// Don't know this message.
LOGGER.error("UnknownMessageTypeException", e);
}
}
use of org.opensmartgridplatform.shared.infra.jms.UnknownMessageTypeException in project open-smart-grid-platform by OSGP.
the class OsgpCoreRequestMessageProcessor method processMessage.
public void processMessage(final RequestMessage requestMessage, final String messageType) throws UnknownMessageTypeException {
final String organisationIdentification = requestMessage.getOrganisationIdentification();
final String deviceIdentification = requestMessage.getDeviceIdentification();
final String correlationUid = requestMessage.getCorrelationUid();
final Object dataObject = requestMessage.getRequest();
LOGGER.info("Received request message from OSGP-CORE with messageType: {} deviceIdentification: {}, organisationIdentification: {}, correlationUid: {}, className: {}", messageType, deviceIdentification, organisationIdentification, correlationUid, dataObject.getClass().getCanonicalName());
if (MessageType.EVENT_NOTIFICATION == MessageType.valueOf(messageType)) {
final Event event = (Event) dataObject;
this.handleLightMeasurementDeviceTransition(organisationIdentification, correlationUid, event);
} else {
throw new UnknownMessageTypeException("Unknown JMSType: " + messageType);
}
}
Aggregations