use of com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage in project Protocol-Adapter-OSLP 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 DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, MessagePriorityEnum.DEFAULT.getPriority());
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(ex).scheduled(isScheduled).retryCount(retryCount).build();
responseMessageSender.send(responseMessage);
}
use of com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage in project Protocol-Adapter-OSLP by OSGP.
the class DeviceRequestMessageProcessor method handleError.
protected void handleError(final Exception e, final String correlationUid, final String organisationIdentification, final String deviceIdentification, final String domain, final String domainVersion, final String messageType) {
LOGGER.error("Error while processing message", e);
final TechnicalException ex = new TechnicalException(ComponentType.PROTOCOL_OSLP, UNEXPECTED_EXCEPTION, e);
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceIdentification, organisationIdentification, correlationUid, messageType, MessagePriorityEnum.DEFAULT.getPriority());
final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(ResponseMessageResultType.NOT_OK).osgpException(ex).build();
this.responseMessageSender.send(protocolResponseMessage);
}
use of com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage in project Protocol-Adapter-OSLP by OSGP.
the class DeviceRequestMessageProcessor method handleEmptyDeviceResponse.
protected void handleEmptyDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType, 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 DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceResponse.getDeviceIdentification(), deviceResponse.getOrganisationIdentification(), deviceResponse.getCorrelationUid(), messageType, MessagePriorityEnum.DEFAULT.getPriority());
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(result).osgpException(ex).retryCount(retryCount).build();
responseMessageSender.send(responseMessage);
}
use of com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage in project Protocol-Adapter-OSLP by OSGP.
the class DeviceRequestMessageProcessor method handleExpectedError.
protected void handleExpectedError(final Exception e, final String correlationUid, final String organisationIdentification, final String deviceIdentification, final String domain, final String domainVersion, final String messageType) {
LOGGER.error("Expected error while processing message", e);
final FunctionalException ex = new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.PROTOCOL_OSLP, e);
final DeviceMessageMetadata deviceMessageMetadata = new DeviceMessageMetadata(deviceIdentification, organisationIdentification, correlationUid, messageType, MessagePriorityEnum.DEFAULT.getPriority());
final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().domain(domain).domainVersion(domainVersion).deviceMessageMetadata(deviceMessageMetadata).result(ResponseMessageResultType.NOT_OK).osgpException(ex).build();
this.responseMessageSender.send(protocolResponseMessage);
}
use of com.alliander.osgp.shared.infra.jms.ProtocolResponseMessage in project Protocol-Adapter-OSLP by OSGP.
the class DeviceResponseMessageSender method send.
@Override
public void send(final ResponseMessage responseMessage) {
if (!(responseMessage instanceof ProtocolResponseMessage)) {
LOGGER.error("Only ProtocolResponseMessage type is expected for DeviceResponseMessageSender");
return;
}
final ProtocolResponseMessage msg = (ProtocolResponseMessage) responseMessage;
if (!this.checkMessage(msg)) {
return;
}
this.sendMessage(msg);
}
Aggregations