use of javax.jms.JMSException in project ACS by ACS-Community.
the class DefaultSubscriberImpl method close.
/**
* Method close
*
*
*/
public void close() {
cat.debug("close()");
synchronized (subscribers) {
SubscriptionHandle handle = null;
keepAliveEnabled = false;
try {
Iterator iterator = subscribers.values().iterator();
while (iterator.hasNext()) {
handle = (SubscriptionHandle) iterator.next();
if (!NotificationHelper.isNotification(handle.getSubscriptionTopic())) {
publishNotification(NotificationHelper.CONSUMER_CLOSE_NOTIFICATION, handle);
}
handle.getSubscriber().close();
handle.getSession().close();
}
subscribers.clear();
if (notificationPublisher != null) {
notificationPublisher.close();
notificationPublisher = null;
}
if (serviceSession != null) {
serviceSession.close();
serviceSession = null;
}
if (topicDirectory != null) {
topicDirectory.clear();
topicDirectory = null;
}
} catch (JMSException e) {
cat.error("Exception raised closing a Subscriber : " + e.getMessage());
}
if (connection != null) {
try {
connection.stop();
} catch (ConnectionException ce) {
ce.printStackTrace();
}
connection.close();
connection = null;
}
closed = true;
}
cat.debug("closed.");
}
use of javax.jms.JMSException in project Protocol-Adapter-IEC61850 by OSGP.
the class PublicLightingGetStatusRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing public lighting get status request message");
String correlationUid = null;
String domain = null;
String domainVersion = null;
String messageType = null;
String organisationIdentification = null;
String deviceIdentification = null;
String ipAddress = null;
int retryCount = 0;
boolean isScheduled = false;
try {
correlationUid = message.getJMSCorrelationID();
domain = message.getStringProperty(Constants.DOMAIN);
domainVersion = message.getStringProperty(Constants.DOMAIN_VERSION);
messageType = message.getJMSType();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
ipAddress = message.getStringProperty(Constants.IP_ADDRESS);
retryCount = message.getIntProperty(Constants.RETRY_COUNT);
isScheduled = message.propertyExists(Constants.IS_SCHEDULED) ? message.getBooleanProperty(Constants.IS_SCHEDULED) : false;
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("domain: {}", domain);
LOGGER.debug("domainVersion: {}", domainVersion);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("ipAddress: {}", ipAddress);
return;
}
final RequestMessageData requestMessageData = new RequestMessageData(null, domain, domainVersion, messageType, retryCount, isScheduled, correlationUid, organisationIdentification, deviceIdentification);
this.printDomainInfo(messageType, domain, domainVersion);
final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
this.deviceService.getStatus(deviceRequest, iec61850DeviceResponseHandler);
}
use of javax.jms.JMSException in project Protocol-Adapter-IEC61850 by OSGP.
the class DeviceRequestMessageListener method onMessage.
/*
* (non-Javadoc)
*
* @see
* org.springframework.jms.listener.SessionAwareMessageListener#onMessage
* (javax.jms.Message, javax.jms.Session)
*/
@Override
public void onMessage(final Message message, final Session session) throws JMSException {
final ObjectMessage objectMessage = (ObjectMessage) message;
String messageType = null;
MessageProcessor processor = null;
try {
messageType = message.getJMSType();
LOGGER.info("Received message of type: {}", messageType);
processor = this.iec61850RequestMessageProcessorMap.getMessageProcessor(objectMessage);
} catch (final IllegalArgumentException | JMSException e) {
LOGGER.error("Unexpected IllegalArgumentException | JMSExceptionduring during onMessage(Message)", e);
this.createAndSendException(objectMessage, messageType);
return;
}
processor.processMessage(objectMessage);
}
use of javax.jms.JMSException in project Protocol-Adapter-IEC61850 by OSGP.
the class DeviceRequestMessageProcessorMap method getMessageProcessor.
@Override
public MessageProcessor getMessageProcessor(final ObjectMessage message) throws JMSException {
if (message.getJMSType() == null) {
LOGGER.error("Unknown message type: {}", message.getJMSType());
throw new JMSException("Unknown message type");
}
final DeviceRequestMessageType messageType = DeviceRequestMessageType.valueOf(message.getJMSType());
if (messageType.name() == null) {
LOGGER.error("No message processor found for message type: {}", message.getJMSType());
throw new JMSException("Unknown message processor for message type: " + message.getJMSType());
}
final MessageProcessor messageProcessor = this.messageProcessors.get(messageType.ordinal());
if (messageProcessor == null) {
LOGGER.error("No message processor instance found in message processor map for message type: {}", message.getJMSType());
throw new JMSException("Unknown message processor");
}
return messageProcessor;
}
use of javax.jms.JMSException in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850LogItemRequestMessageSender method send.
public void send(final Iec61850LogItemRequestMessage iec61850LogItemRequestMessage) {
LOGGER.debug("Sending Iec61850LogItemRequestMessage");
this.iec61850LogItemRequestsJmsTemplate.send(new MessageCreator() {
@Override
public Message createMessage(final Session session) throws JMSException {
final ObjectMessage objectMessage = session.createObjectMessage();
objectMessage.setJMSType(Constants.IEC61850_LOG_ITEM_REQUEST);
objectMessage.setStringProperty(Constants.IS_INCOMING, iec61850LogItemRequestMessage.isIncoming().toString());
objectMessage.setStringProperty(Constants.ENCODED_MESSAGE, iec61850LogItemRequestMessage.getEncodedMessage());
objectMessage.setStringProperty(Constants.DECODED_MESSAGE, iec61850LogItemRequestMessage.getDecodedMessage());
objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION, iec61850LogItemRequestMessage.getDeviceIdentification());
objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION, iec61850LogItemRequestMessage.getOrganisationIdentification());
objectMessage.setStringProperty(Constants.IS_VALID, iec61850LogItemRequestMessage.isValid().toString());
objectMessage.setIntProperty(Constants.PAYLOAD_MESSAGE_SERIALIZED_SIZE, iec61850LogItemRequestMessage.getPayloadMessageSerializedSize());
return objectMessage;
}
});
}
Aggregations