use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class PublicLightingSetTransitionResponseMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing public lighting set transition response message");
String correlationUid = null;
String messageType = null;
int messagePriority = MessagePriorityEnum.DEFAULT.getPriority();
String organisationIdentification = null;
String deviceIdentification = null;
ResponseMessage responseMessage;
ResponseMessageResultType responseMessageResultType = null;
OsgpException osgpException = null;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
messagePriority = message.getJMSPriority();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
responseMessage = (ResponseMessage) message.getObject();
responseMessageResultType = responseMessage.getResult();
osgpException = responseMessage.getOsgpException();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("messagePriority: {}", messagePriority);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("responseMessageResultType: {}", responseMessageResultType);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("osgpException", osgpException);
return;
}
try {
LOGGER.info("Calling application service function to handle response: {}", messageType);
if (this.isSetTransitionResponseLoggingEnabled) {
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.adHocManagementService.handleSetTransitionResponse(ids, messageType, messagePriority, responseMessageResultType, osgpException);
} else {
final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
this.defaultDeviceResponseService.handleDefaultDeviceResponse(ids, messageType, messagePriority, responseMessageResultType, osgpException);
}
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType, messagePriority);
}
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class WebServiceResponseMessageSender method send.
/**
* Send a response message to the web service adapter using a custom time to live.
*
* @param responseMessage The response message to send.
* @param timeToLive The custom time to live value in milliseconds.
*/
public void send(final ResponseMessage responseMessage, final Long timeToLive) {
// Keep the original time to live from configuration.
final Long originalTimeToLive = this.webServiceResponsesJmsTemplate.getTimeToLive();
if (timeToLive != null) {
// Set the custom time to live.
this.webServiceResponsesJmsTemplate.setTimeToLive(timeToLive);
}
this.webServiceResponsesJmsTemplate.send(new MessageCreator() {
@Override
public Message createMessage(final Session session) throws JMSException {
final ObjectMessage objectMessage = session.createObjectMessage(responseMessage);
objectMessage.setJMSType(responseMessage.getMessageType());
objectMessage.setJMSPriority(responseMessage.getMessagePriority());
objectMessage.setJMSCorrelationID(responseMessage.getCorrelationUid());
objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION, responseMessage.getOrganisationIdentification());
objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION, responseMessage.getDeviceIdentification());
objectMessage.setStringProperty(Constants.RESULT, responseMessage.getResult().toString());
if (responseMessage.getOsgpException() != null) {
objectMessage.setStringProperty(Constants.DESCRIPTION, responseMessage.getOsgpException().getMessage());
}
return objectMessage;
}
});
if (timeToLive != null) {
// Restore the time to live from the configuration.
this.webServiceResponsesJmsTemplate.setTimeToLive(originalTimeToLive);
}
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class AdhocService method handleScanMbusChannelsResponse.
public void handleScanMbusChannelsResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception, final ScanMbusChannelsResponseDto resultData) {
LOGGER.debug("handleScanMbusChannelsResponse for MessageType: {}", messageMetadata.getMessageType());
ResponseMessageResultType result = deviceResult;
if (exception != null) {
LOGGER.error(DEVICE_RESPONSE_NOT_OK_UNEXPECTED_EXCEPTION, exception);
result = ResponseMessageResultType.NOT_OK;
}
final ScanMbusChannelsResponseData scanMbusChannelsResponseData = this.mapperFactory.getMapperFacade().map(resultData, ScanMbusChannelsResponseData.class);
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).withDataObject(scanMbusChannelsResponseData).build();
this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class AdhocService method handleGetAllAttributeValuesResponse.
public void handleGetAllAttributeValuesResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception, final String resultData) {
LOGGER.debug("handleGetAllAttributeValuesResponse for MessageType: {}", messageMetadata.getMessageType());
ResponseMessageResultType result = deviceResult;
if (exception != null) {
LOGGER.error(DEVICE_RESPONSE_NOT_OK_UNEXPECTED_EXCEPTION, exception);
result = ResponseMessageResultType.NOT_OK;
}
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).withDataObject(resultData).build();
this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class AdhocService method handleGetSpecificAttributeValueResponse.
public void handleGetSpecificAttributeValueResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception, final String resultData) {
LOGGER.debug("handleGetSpecificAttributeValueResponse for MessageType: {}", messageMetadata.getMessageType());
ResponseMessageResultType result = deviceResult;
if (exception != null) {
LOGGER.error(DEVICE_RESPONSE_NOT_OK_UNEXPECTED_EXCEPTION, exception);
result = ResponseMessageResultType.NOT_OK;
}
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).withDataObject(resultData).build();
this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
Aggregations