private void closeSession(ClientSession createSession) { if (createSession != null) { try { createSession.close(); } catch (HornetQException e) { } } }
public void cleanup() { for (Pooled pooled : pool) { try { pooled.session.close(); } catch (HornetQException e) { throw new RuntimeException(e); } } }
/** * Closes the passed-in {@link ClientSession}. * * @param session the {@link ClientSession} instance to close. */ public static void closeSession(final ClientSession session) { if (session != null) { try { session.close(); } catch (final HornetQException ignore) { ignore.printStackTrace(); } } }
/** * Closes the passed-in {@link ClientSession}. * * @param session the {@link ClientSession} instance to close. */ public static void closeSession(final ClientSession session) { if (session != null) { try { session.close(); } catch (final HornetQException ignore) { ignore.printStackTrace(); } } }
public void stop() { for (ClientSession session : sessions) { try { if (session != null) { session.close(); } } catch (HornetQException e) { } } try { if (strategy != null) { strategy.stop(); } } catch (Exception e) { } }
/** * Closes the ClientRequestor and its session. * * @throws Exception if an exception occurs while closing the ClientRequestor */ public void close() throws Exception { replyConsumer.close(); queueSession.deleteQueue(replyQueue); queueSession.close(); }
public void close() throws JMSException { synchronized (connection) { try { for (HornetQMessageConsumer cons : new HashSet<HornetQMessageConsumer>(consumers)) { cons.close(); } session.close(); connection.removeSession(this); } catch (HornetQException e) { throw JMSExceptionHelper.convertFromHornetQException(e); } } }
static boolean queueExists(final String queueName, final ClientSessionFactory sf) throws HornetQException { final ClientSession session = sf.createSession(false, false, false); try { final QueueQuery query = session.queueQuery(new SimpleString(queueName)); return query.isExists(); } finally { session.close(); } }
public synchronized void shutdown() { if (closed) return; closed = true; lastConsumed = null; previousIndex = -2; try { consumer.close(); HornetQRestLogger.LOGGER.debug("Closed consumer: " + consumer); } catch (Exception e) { } try { session.close(); HornetQRestLogger.LOGGER.debug("Closed session: " + session); } catch (Exception e) { } session = null; consumer = null; }
private void deleteSubscriberQueue(QueueConsumer consumer) { String subscriptionName = consumer.getId(); ClientSession session = null; try { session = sessionFactory.createSession(); session.deleteQueue(subscriptionName); } catch (HornetQException e) { } finally { if (session != null) { try { session.close(); } catch (HornetQException e) { } } } } }
session.close();
private boolean subscriptionExists(String subscriptionId) { ClientSession session = null; try { session = sessionFactory.createSession(); ClientSession.QueueQuery query = session.queueQuery(new SimpleString(subscriptionId)); return query.isExists(); } catch (HornetQException e) { throw new RuntimeException(e); } finally { if (session != null) { try { session.close(); } catch (HornetQException e) { } } } }
@DELETE public void deleteQueue(@Context UriInfo uriInfo) throws Exception { HornetQRestLogger.LOGGER.debug("Handling DELETE request for \"" + uriInfo.getPath() + "\""); queueDestinationsResource.getQueues().remove(destination); stop(); ClientSession session = serviceManager.getSessionFactory().createSession(false, false, false); try { SimpleString queueName = new SimpleString(destination); session.deleteQueue(queueName); } finally { try { session.close(); } catch (Exception ignored) { } } }
@DELETE public void deleteTopic(@Context UriInfo uriInfo) throws Exception { HornetQRestLogger.LOGGER.debug("Handling DELETE request for \"" + uriInfo.getPath() + "\""); topicDestinationsResource.getTopics().remove(destination); try { stop(); } catch (Exception ignored) { } ClientSession session = serviceManager.getSessionFactory().createSession(false, false, false); try { SimpleString topicName = new SimpleString(destination); session.deleteQueue(topicName); } finally { try { session.close(); } catch (Exception ignored) { } } }
protected void deleteSubscriberQueue() { String subscriptionName = registration.getDestination(); ClientSession session = null; try { session = factory.createSession(); session.deleteQueue(subscriptionName); } catch (HornetQException e) { HornetQRestLogger.LOGGER.errorDeletingSubscriberQueue(e); } finally { try { if (session != null) session.close(); } catch (HornetQException e) { } } } }
public void deploy(QueueDeployment queueDeployment) throws Exception { if (!started) { throw new Exception("You must start() this class instance before deploying"); } String queueName = queueDeployment.getName(); ClientSession session = sessionFactory.createSession(false, false, false); ClientSession.QueueQuery query = session.queueQuery(new SimpleString(queueName)); if (!query.isExists()) { session.createQueue(queueName, queueName, queueDeployment.isDurableSend()); } session.close(); destination.createQueueResource(queueName, queueDeployment.isDurableSend(), queueDeployment.getConsumerSessionTimeoutSeconds(), queueDeployment.isDuplicatesAllowed()); }
public void publish(HttpHeaders headers, byte[] body, boolean durable, Long ttl, Long expiration, Integer priority) throws Exception { Pooled pooled = getPooled(); try { ClientProducer producer = pooled.producer; ClientMessage message = createHornetQMessage(headers, body, durable, ttl, expiration, priority, pooled.session); producer.send(message); HornetQRestLogger.LOGGER.debug("Sent message: " + message); pool.add(pooled); } catch (Exception ex) { try { pooled.session.close(); } catch (HornetQException e) { } addPooled(); throw ex; } }
public void deploy(TopicDeployment topicDeployment) throws Exception { if (!started) { throw new Exception("You must start() this class instance before deploying"); } String queueName = topicDeployment.getName(); ClientSession session = sessionFactory.createSession(false, false, false); ClientSession.QueueQuery query = session.queueQuery(new SimpleString(queueName)); boolean defaultDurable = topicDeployment.isDurableSend(); if (query.isExists()) { defaultDurable = query.isDurable(); } else { session.createQueue(queueName, queueName, topicDeployment.isDurableSend()); } session.close(); destination.createTopicResource(queueName, defaultDurable, topicDeployment.getConsumerSessionTimeoutSeconds(), topicDeployment.isDuplicatesAllowed()); }
public void publish(HttpHeaders headers, byte[] body, String dup, boolean durable, Long ttl, Long expiration, Integer priority) throws Exception { Pooled pooled = getPooled(); try { ClientProducer producer = pooled.producer; ClientMessage message = createHornetQMessage(headers, body, durable, ttl, expiration, priority, pooled.session); message.putStringProperty(ClientMessage.HDR_DUPLICATE_DETECTION_ID.toString(), dup); producer.send(message); HornetQRestLogger.LOGGER.debug("Sent message: " + message); pool.add(pooled); } catch (Exception ex) { try { pooled.session.close(); } catch (HornetQException e) { } addPooled(); throw ex; } }