use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class DeviceRequestMessageProcessor method handleScheduledEmptyDeviceResponse.
protected void handleScheduledEmptyDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, final boolean isScheduled, final int retryCount) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
TechnicalException ex = null;
try {
final EmptyDeviceResponse response = (EmptyDeviceResponse) deviceResponse;
this.deviceResponseService.handleDeviceMessageStatus(response.getStatus());
} catch (final TechnicalException e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
ex = e;
}
final MessageMetadata messageMetadata = MessageMetadataFactory.from(deviceResponse, messageType).builder().withDomain(domain).withDomainVersion(domainVersion).withScheduled(isScheduled).withRetryCount(retryCount).build();
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).result(result).osgpException(ex).build();
responseMessageSender.send(responseMessage);
}
use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class DeviceRequestMessageProcessor method handleUnableToConnectDeviceResponse.
public void handleUnableToConnectDeviceResponse(final DeviceResponse deviceResponse, final Throwable t, final String domain, final String domainVersion, final String messageType, final boolean isScheduled, final int retryCount) {
LOGGER.error("Error while connecting to or communicating with device", t);
final ResponseMessageResultType result = ResponseMessageResultType.NOT_OK;
// Set the exception to a class known by all OSGP components
final TechnicalException ex = new TechnicalException(ComponentType.PROTOCOL_OSLP, StringUtils.isBlank(t.getMessage()) ? UNEXPECTED_EXCEPTION : t.getMessage());
final MessageMetadata messageMetadata = MessageMetadataFactory.from(deviceResponse, messageType).builder().withDomain(domain).withDomainVersion(domainVersion).withScheduled(isScheduled).withRetryCount(retryCount).build();
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).result(result).osgpException(ex).build();
this.responseMessageSender.send(responseMessage);
}
use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class DeviceRequestMessageProcessor method handleError.
protected void handleError(final RuntimeException e, final MessageMetadata messageMetadata) {
LOGGER.error("Error while processing message, using MessageMetadata to create error response", e);
// Set the exception to a class known by all OSGP components
final TechnicalException ex = new TechnicalException(ComponentType.PROTOCOL_OSLP, UNEXPECTED_EXCEPTION);
final ProtocolResponseMessage protocolResponseMessage = this.createProtocolResponseMessage(messageMetadata, ex);
this.responseMessageSender.send(protocolResponseMessage);
}
use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class DeviceRequestMessageProcessor method handleError.
protected void handleError(final IOException e, final String correlationUid, final String organisationIdentification, final String deviceIdentification, final String domain, final String domainVersion, final String messageType, final int messagePriority, final int retryCount) {
LOGGER.error("Error while processing message", e);
// Set the exception to a class known by all OSGP components
final TechnicalException ex = new TechnicalException(ComponentType.PROTOCOL_OSLP, UNEXPECTED_EXCEPTION);
final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(messageType).withDomain(domain).withDomainVersion(domainVersion).withMessagePriority(messagePriority).withRetryCount(retryCount).build();
final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).result(ResponseMessageResultType.NOT_OK).osgpException(ex).build();
this.responseMessageSender.send(protocolResponseMessage);
}
use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class DeviceRequestMessageProcessor method handleFunctionalException.
protected void handleFunctionalException(final FunctionalException e, final MessageMetadata messageMetadata) {
LOGGER.error("Functional error while processing message, using MessageMetadata to create error response", e);
final ProtocolResponseMessage protocolResponseMessage = this.createProtocolResponseMessage(messageMetadata, e);
this.responseMessageSender.send(protocolResponseMessage);
}
Aggregations