use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class BaseMessageProcessor method handleExpectedError.
protected void handleExpectedError(final DeviceResponse deviceResponse, final OsgpException e, final DomainInformation domainInformation, final String messageType, final boolean isScheduled) {
LOGGER.error("Expected error while processing message", e);
final int retryCount = Integer.MAX_VALUE;
final MessageMetadata deviceMessageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceResponse.getDeviceIdentification()).withOrganisationIdentification(deviceResponse.getOrganisationIdentification()).withCorrelationUid(deviceResponse.getCorrelationUid()).withMessageType(messageType).withDomain(domainInformation.getDomain()).withDomainVersion(domainInformation.getDomainVersion()).withMessagePriority(deviceResponse.getMessagePriority()).withScheduled(isScheduled).withRetryCount(retryCount).build();
final ProtocolResponseMessage protocolResponseMessage = new ProtocolResponseMessage.Builder().messageMetadata(deviceMessageMetadata).result(ResponseMessageResultType.NOT_OK).osgpException(e).build();
this.responseMessageSender.send(protocolResponseMessage);
}
use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class DaRtuDeviceRequestMessageProcessor method handleDeviceResponse.
/**
* Override to include the data in the response
*/
@Override
public void handleDeviceResponse(final DeviceResponse deviceResponse, final ResponseMessageSender responseMessageSender, final DomainInformation domainInformation, final String messageType, final int retryCount, final boolean isScheduled) {
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException ex = null;
Serializable dataObject = null;
try {
final DaDeviceResponse response = (DaDeviceResponse) deviceResponse;
this.deviceResponseService.handleDeviceMessageStatus(response.getStatus());
dataObject = response.getDataResponse();
} catch (final OsgpException e) {
LOGGER.error("Device Response Exception", e);
result = ResponseMessageResultType.NOT_OK;
ex = e;
}
final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withDeviceIdentification(deviceResponse.getDeviceIdentification()).withOrganisationIdentification(deviceResponse.getOrganisationIdentification()).withCorrelationUid(deviceResponse.getCorrelationUid()).withMessageType(messageType).withDomain(domainInformation.getDomain()).withDomainVersion(domainInformation.getDomainVersion()).withScheduled(isScheduled).withRetryCount(retryCount).build();
final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).result(result).osgpException(ex).dataObject(dataObject).build();
responseMessageSender.send(protocolResponseMessage);
}
Aggregations