Search in sources :

Example 46 with ProtocolResponseMessage

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

Example 47 with 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);
}
Also used : DaDeviceResponse(org.opensmartgridplatform.adapter.protocol.iec61850.device.da.rtu.DaDeviceResponse) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) Serializable(java.io.Serializable) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) ProtocolResponseMessage(org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)

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