use of javax.jms.JMSException in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850SsldDeviceService method setTransition.
@Override
public void setTransition(final SetTransitionDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
DeviceConnection devCon = null;
try {
final DeviceConnection deviceConnection = this.connectToDevice(deviceRequest);
devCon = deviceConnection;
new Iec61850TransitionCommand().transitionDevice(this.iec61850Client, deviceConnection, deviceRequest.getTransitionTypeContainer());
this.createSuccessfulDefaultResponse(deviceRequest, deviceResponseHandler);
this.enableReporting(deviceConnection, deviceRequest);
} catch (final ConnectionFailureException se) {
this.handleConnectionFailureException(deviceRequest, deviceResponseHandler, se);
this.iec61850DeviceConnectionService.disconnect(devCon, deviceRequest);
} catch (final Exception e) {
this.handleException(deviceRequest, deviceResponseHandler, e);
this.iec61850DeviceConnectionService.disconnect(devCon, deviceRequest);
}
}
use of javax.jms.JMSException in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850SsldDeviceService method updateFirmware.
@Override
public void updateFirmware(final UpdateFirmwareDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
DeviceConnection deviceConnection = null;
try {
deviceConnection = this.connectToDevice(deviceRequest);
new Iec61850UpdateFirmwareCommand().pushFirmwareToDevice(this.iec61850Client, deviceConnection, deviceRequest.getFirmwareDomain().concat(deviceRequest.getFirmwareUrl()), deviceRequest.getFirmwareModuleData());
this.createSuccessfulDefaultResponse(deviceRequest, deviceResponseHandler);
} catch (final ConnectionFailureException se) {
this.handleConnectionFailureException(deviceRequest, deviceResponseHandler, se);
} catch (final Exception e) {
this.handleException(deviceRequest, deviceResponseHandler, e);
}
this.iec61850DeviceConnectionService.disconnect(deviceConnection, deviceRequest);
}
use of javax.jms.JMSException in project Protocol-Adapter-IEC61850 by OSGP.
the class BaseMessageProcessor method checkForRedelivery.
/**
* Use 'jmsxDeliveryCount' to determine if a request should be retried using
* the re-delivery options. In case a JMSException is thrown, the request
* will be rolled-back to the message-broker and will be re-delivered
* according to the re-delivery policy set. If the maximum number of
* re-deliveries have been executed, a protocol response message will be
* sent to osgp-core.
*/
public void checkForRedelivery(final DeviceMessageMetadata deviceMessageMetadata, final OsgpException e, final String domain, final String domainVersion, final int jmsxDeliveryCount) throws JMSException {
final int jmsxRedeliveryCount = jmsxDeliveryCount - 1;
LOGGER.info("jmsxDeliveryCount: {}, jmsxRedeliveryCount: {}, maxRedeliveriesForIec61850Requests: {}", jmsxDeliveryCount, jmsxRedeliveryCount, this.maxRedeliveriesForIec61850Requests);
if (jmsxRedeliveryCount < this.maxRedeliveriesForIec61850Requests) {
LOGGER.info("Redelivering message with messageType: {}, correlationUid: {}, for device: {} - jmsxRedeliveryCount: {} is less than maxRedeliveriesForIec61850Requests: {}", deviceMessageMetadata.getMessageType(), deviceMessageMetadata.getCorrelationUid(), deviceMessageMetadata.getDeviceIdentification(), jmsxRedeliveryCount, this.maxRedeliveriesForIec61850Requests);
final JMSException jmsException = new JMSException(e == null ? "checkForRedelivery() unknown error: OsgpException e is null" : e.getMessage());
throw JmsUtils.convertJmsAccessException(jmsException);
} else {
LOGGER.warn("All redelivery attempts failed for message with messageType: {}, correlationUid: {}, for device: {}", deviceMessageMetadata.getMessageType(), deviceMessageMetadata.getDeviceIdentification(), deviceMessageMetadata.getCorrelationUid());
this.handleExpectedError(e, deviceMessageMetadata.getCorrelationUid(), deviceMessageMetadata.getOrganisationIdentification(), deviceMessageMetadata.getDeviceIdentification(), domain, domainVersion, deviceMessageMetadata.getMessageType());
}
}
use of javax.jms.JMSException in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850DaRtuDeviceService method getData.
@Override
public void getData(final DaDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler, final DaRtuDeviceRequestMessageProcessor messageProcessor) throws JMSException {
try {
final String serverName = this.getServerName(deviceRequest);
final ServerModel serverModel = this.connectAndRetrieveServerModel(deviceRequest, serverName);
final ClientAssociation clientAssociation = this.iec61850DeviceConnectionService.getClientAssociation(deviceRequest.getDeviceIdentification());
final Serializable dataResponse = this.handleGetData(new DeviceConnection(new Iec61850Connection(new Iec61850ClientAssociation(clientAssociation, null), serverModel), deviceRequest.getDeviceIdentification(), deviceRequest.getOrganisationIdentification(), serverName), deviceRequest, messageProcessor);
final DaDeviceResponse deviceResponse = new DaDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.OK, dataResponse);
deviceResponseHandler.handleResponse(deviceResponse);
} catch (final ConnectionFailureException se) {
LOGGER.error("Could not connect to device after all retries", se);
final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.FAILURE);
deviceResponseHandler.handleConnectionFailure(se, deviceResponse);
} catch (final Exception e) {
LOGGER.error("Unexpected exception during Get Data", e);
final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.FAILURE);
deviceResponseHandler.handleException(e, deviceResponse);
}
}
use of javax.jms.JMSException in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850RtuDeviceService method setData.
@Override
public void setData(final SetDataDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
try {
final String serverName = this.getServerName(deviceRequest);
final ServerModel serverModel = this.connectAndRetrieveServerModel(deviceRequest, serverName);
final ClientAssociation clientAssociation = this.iec61850DeviceConnectionService.getClientAssociation(deviceRequest.getDeviceIdentification());
this.handleSetData(new DeviceConnection(new Iec61850Connection(new Iec61850ClientAssociation(clientAssociation, null), serverModel), deviceRequest.getDeviceIdentification(), deviceRequest.getOrganisationIdentification(), serverName), deviceRequest);
final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.OK);
deviceResponseHandler.handleResponse(deviceResponse);
} catch (final ConnectionFailureException se) {
LOGGER.error("Could not connect to device after all retries", se);
final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.FAILURE);
deviceResponseHandler.handleConnectionFailure(se, deviceResponse);
} catch (final Exception e) {
LOGGER.error("Unexpected exception during Set Data", e);
final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.FAILURE);
deviceResponseHandler.handleException(e, deviceResponse);
}
}
Aggregations