use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform 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 (!ProtocolResponseMessageValidator.isValid(msg, LOGGER)) {
return;
}
this.sendMessage(msg);
}
use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class DeviceManagementService method sendResponseMessage.
private void sendResponseMessage(final MessageMetadata messageMetadata, final ResponseMessageResultType result, final OsgpException osgpException, final DeviceResponseMessageSender responseMessageSender) {
final ProtocolResponseMessage responseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).result(result).osgpException(osgpException).build();
responseMessageSender.send(responseMessage);
}
use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class OslpSigningService method handleError.
/**
* Handle an error from the signing server.
*/
public void handleError(final String deviceIdentification, final ResponseMessage responseMessage) {
final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = (UnsignedOslpEnvelopeDto) responseMessage.getDataObject();
final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(unsignedOslpEnvelopeDto.getOrganisationIdentification()).withCorrelationUid(unsignedOslpEnvelopeDto.getCorrelationUid()).withMessageType(unsignedOslpEnvelopeDto.getMessageType()).withDomain(unsignedOslpEnvelopeDto.getDomain()).withDomainVersion(unsignedOslpEnvelopeDto.getDomainVersion()).withMessagePriority(responseMessage.getMessagePriority()).withScheduled(unsignedOslpEnvelopeDto.isScheduled()).build();
final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).result(responseMessage.getResult()).osgpException(responseMessage.getOsgpException()).build();
this.deviceResponseMessageSender.send(protocolResponseMessage);
}
use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class Iec61850DeviceResponseHandler method handleException.
/*
* (non-Javadoc)
*
* @see org.opensmartgridplatform.adapter.protocol.iec61850.device.
* DeviceResponseHandler #handleException(java.lang.Throwable,
* org.opensmartgridplatform.adapter.protocol.iec61850.device.
* DeviceResponse)
*/
@Override
public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
Objects.requireNonNull(t, "handleException() Throwable t may not be null");
final OsgpException ex = this.ensureOsgpException(t);
final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(this.messageMetadata.builder().withDomain(this.domainInformation.getDomain()).withDomainVersion(this.domainInformation.getDomainVersion()).withScheduled(this.isScheduled).withRetryCount(this.retryCount).build()).result(ResponseMessageResultType.NOT_OK).osgpException(ex).dataObject(this.messageData).build();
this.responseMessageSender.send(protocolResponseMessage);
}
use of org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage in project open-smart-grid-platform by OSGP.
the class AbstractMessageProcessor method handleError.
protected void handleError(final MessageMetadata messageMetadata, final ProtocolAdapterException e) {
LOGGER.warn("Error while processing message", e);
this.pendingRequestsQueue.remove(messageMetadata.getDeviceIdentification(), messageMetadata.getCorrelationUid());
final ProtocolResponseMessage protocolResponseMessage = ProtocolResponseMessage.newBuilder().messageMetadata(messageMetadata).result(ResponseMessageResultType.NOT_OK).osgpException(e).build();
if (this.hasRemainingRedeliveries(messageMetadata)) {
this.redeliverMessage(messageMetadata, e);
} else {
this.sendErrorResponse(messageMetadata, protocolResponseMessage);
}
}
Aggregations