/** * {@inheritDoc} * * @see org.eclipse.smila.connectivity.queue.worker.internal.AbstractQueueService#start() */ @Override public synchronized void start() { _log.info(msg("Starting...")); try { super.start(); for (final BrokerConnectionType connectionType : _config.getConnectionConfig()) { final String id = connectionType.getId(); if (_connectionAccessMap.containsKey(id)) { throw new RuntimeException( msg(String.format("Broker with ID %s already registered", id))); } _connectionAccessMap.put( connectionType.getId(), new BrokerConnectionAccess(connectionType)); } _log.info(msg("Started successfully")); } catch (final RuntimeException e) { _log.error(msg("Error starting"), e); throw e; } }
/** * {@inheritDoc} * * @see org.eclipse.smila.connectivity.queue.worker.internal.AbstractQueueService#stop() */ @Override public synchronized void stop() { _connectionAccessMap.clear(); synchronized (_connectionCache) { final Iterator<ConnectionWrapper> iterator = _connectionCache.values().iterator(); while (iterator.hasNext()) { final ConnectionWrapper connection = iterator.next(); try { connection.stopInternal(); } catch (final Throwable e) { _log.error(msg("While stopping JMS connection"), e); } try { connection.closeInternal(); } catch (final Throwable e) { _log.error(msg("While closing JMS connection"), e); } iterator.remove(); } } super.stop(); }