Search in sources :

Example 26 with ProtocolResponseMessage

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);
}
Also used : ProtocolResponseMessage(org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)

Example 27 with ProtocolResponseMessage

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);
}
Also used : ProtocolResponseMessage(org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)

Example 28 with ProtocolResponseMessage

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);
}
Also used : UnsignedOslpEnvelopeDto(org.opensmartgridplatform.oslp.UnsignedOslpEnvelopeDto) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) ProtocolResponseMessage(org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)

Example 29 with 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);
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ProtocolResponseMessage(org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)

Example 30 with 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);
    }
}
Also used : ProtocolResponseMessage(org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)

Aggregations

ProtocolResponseMessage (org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)47 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)18 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)17 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)14 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)13 JMSException (javax.jms.JMSException)12 Serializable (java.io.Serializable)6 IOException (java.io.IOException)5 Test (org.junit.jupiter.api.Test)5 DeviceStatusDto (org.opensmartgridplatform.dto.valueobjects.DeviceStatusDto)4 GetStatusDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.GetStatusDeviceResponse)3 ScheduledTask (org.opensmartgridplatform.domain.core.entities.ScheduledTask)3 NotSupportedException (org.opensmartgridplatform.shared.exceptionhandling.NotSupportedException)3 RetryHeader (org.opensmartgridplatform.shared.infra.jms.RetryHeader)3 Calendar (java.util.Calendar)2 Date (java.util.Date)2 EmptyDeviceResponse (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.responses.EmptyDeviceResponse)2 ConfigurationDto (org.opensmartgridplatform.dto.valueobjects.ConfigurationDto)2 FirmwareFileDto (org.opensmartgridplatform.dto.valueobjects.FirmwareFileDto)2 FirmwareVersionDto (org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto)2