use of javax.jms.JMSException in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850RtuDeviceService method getData.
@Override
public void getData(final GetDataDeviceRequest 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());
final GetDataResponseDto getDataResponse = this.handleGetData(new DeviceConnection(new Iec61850Connection(new Iec61850ClientAssociation(clientAssociation, null), serverModel), deviceRequest.getDeviceIdentification(), deviceRequest.getOrganisationIdentification(), serverName), deviceRequest);
final GetDataDeviceResponse deviceResponse = new GetDataDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.OK, getDataResponse);
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 Iec61850SsldDeviceService method setSchedule.
@Override
public void setSchedule(final SetScheduleDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
DeviceConnection deviceConnection = null;
try {
deviceConnection = this.connectToDevice(deviceRequest);
// Getting the SSLD for the device output-settings.
final Ssld ssld = this.ssldDataService.findDevice(deviceRequest.getDeviceIdentification());
new Iec61850SetScheduleCommand().setScheduleOnDevice(this.iec61850Client, deviceConnection, deviceRequest.getRelayType(), deviceRequest.getScheduleMessageDataContainer().getScheduleList(), ssld, this.ssldDataService);
this.createSuccessfulDefaultResponse(deviceRequest, deviceResponseHandler);
} catch (final ConnectionFailureException se) {
this.handleConnectionFailureException(deviceRequest, deviceResponseHandler, se);
} catch (final ProtocolAdapterException e) {
this.handleProtocolAdapterException(deviceRequest, deviceResponseHandler, e);
} 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 Iec61850SsldDeviceService method getStatus.
@Override
public void getStatus(final DeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
DeviceConnection devCon = null;
try {
final DeviceConnection deviceConnection = this.connectToDevice(deviceRequest);
devCon = deviceConnection;
// Getting the SSLD for the device output-settings.
final Ssld ssld = this.ssldDataService.findDevice(deviceRequest.getDeviceIdentification());
final DeviceStatusDto deviceStatus = new Iec61850GetStatusCommand().getStatusFromDevice(this.iec61850Client, deviceConnection, ssld);
final GetStatusDeviceResponse deviceResponse = new GetStatusDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), deviceStatus);
deviceResponseHandler.handleResponse(deviceResponse);
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 javaee7-samples by javaee-samples.
the class ClassicMessageReceiver method receiveMessage.
public String receiveMessage() {
String response = null;
Connection connection = null;
try {
connection = connectionFactory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer messageConsumer = session.createConsumer(demoQueue);
Message message = messageConsumer.receive(5000);
response = message.getBody(String.class);
} catch (JMSException ex) {
ex.printStackTrace();
} finally {
if (connection != null) {
try {
connection.close();
} catch (JMSException ex) {
ex.printStackTrace();
}
}
}
return response;
}
use of javax.jms.JMSException in project javaee7-samples by javaee-samples.
the class MessageReceiverSync method receiveAll.
public void receiveAll() {
System.out.println("--> Receiving redundant messages ...");
try {
QueueBrowser browser = context.createBrowser(myQueue);
while (browser.getEnumeration().hasMoreElements()) {
System.out.println("--> here is one");
context.createConsumer(myQueue).receiveBody(String.class, 1000);
}
} catch (JMSException ex) {
Logger.getLogger(MessageReceiverSync.class.getName()).log(Level.SEVERE, null, ex);
}
}
Aggregations