use of org.opensmartgridplatform.shared.infra.jms.UnknownMessageTypeException 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.getJMSType());
final ObjectMessage objectMessage = (ObjectMessage) message;
final String messageType = objectMessage.getJMSType();
final String deviceIdentification = objectMessage.getStringProperty(Constants.DEVICE_IDENTIFICATION);
final ResponseMessage responseMessage = (ResponseMessage) objectMessage.getObject();
final String result = responseMessage == null ? null : responseMessage.getResult().toString();
final OsgpException osgpException = responseMessage == null ? null : responseMessage.getOsgpException();
if (MessageType.valueOf(messageType) == (MessageType.REGISTER_DEVICE)) {
handleDeviceRegistration(result, deviceIdentification, messageType, osgpException);
} else {
throw new UnknownMessageTypeException("Unknown JMSType: " + messageType);
}
} catch (final JMSException ex) {
LOGGER.error("Exception: {} ", ex.getMessage(), ex);
} catch (final ProtocolAdapterException e) {
LOGGER.error("ProtocolAdapterException", e);
} catch (final UnknownMessageTypeException e) {
LOGGER.error("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.messageProcessor.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 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 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.messageProcessor.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 OsgpResponseMessageListener 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 messageType = objectMessage.getJMSType();
final String deviceIdentification = objectMessage.getStringProperty(Constants.DEVICE_IDENTIFICATION);
final ResponseMessage responseMessage = (ResponseMessage) objectMessage.getObject();
final String result = responseMessage == null ? null : responseMessage.getResult().toString();
final OsgpException osgpException = responseMessage == null ? null : responseMessage.getOsgpException();
if (MessageType.REGISTER_DEVICE.name().equals(messageType)) {
if (ResponseMessageResultType.valueOf(result).equals(ResponseMessageResultType.NOT_OK)) {
throw new ProtocolAdapterException(String.format("Response for device: %s for MessageType: %s is: %s, error: %s", deviceIdentification, messageType, result, osgpException));
} else {
throw new UnknownMessageTypeException("Unknown JMSType: " + messageType);
}
}
} catch (final JMSException ex) {
LOGGER.error("Exception: {} ", ex.getMessage(), ex);
} catch (final ProtocolAdapterException e) {
LOGGER.error("ProtocolAdapterException", e);
} catch (final UnknownMessageTypeException e) {
LOGGER.error("UnknownMessageTypeException", e);
}
}
Aggregations