public XmlDataImporter(InputStream inputStream, String host, String port, boolean transactional) { try { reader = XMLInputFactory.newInstance().createXMLStreamReader(inputStream); HashMap<String, Object> connectionParams = new HashMap<String, Object>(); connectionParams.put(TransportConstants.HOST_PROP_NAME, host); connectionParams.put(TransportConstants.PORT_PROP_NAME, port); ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams)); ClientSessionFactory sf = serverLocator.createSessionFactory(); session = sf.createSession(false, !transactional, true); managementSession = sf.createSession(false, true, true); localSession = true; } catch (Exception e) { e.printStackTrace(); } }
public ClientSession createSubscription(String subscriptionName, boolean durable) { ClientSession session = null; try { session = sessionFactory.createSession(); if (durable) { session.createQueue(destination, subscriptionName, true); } else { session.createTemporaryQueue(destination, subscriptionName); } return session; } catch (HornetQException e) { throw new RuntimeException(e); } }
@Override public void stop() throws Exception { shutdown.set(true); if (session != null) session.close(); ClientSession coreSession = sf.createSession(false, false, false); coreSession.deleteQueue(QUEUE_EXAMPLE_QUEUE); coreSession.close(); }
public void authorize() throws JMSException { try { initialSession = sessionFactory.createSession(username, password, false, false, false, false, 0); addSessionMetaData(initialSession); initialSession.addFailureListener(listener); } catch (HornetQException me) { throw JMSExceptionHelper.convertFromHornetQException(me); } }
private void deleteSubscriberQueue(PushConsumer consumer) { String subscriptionName = consumer.getDestination(); ClientSession session = null; try { session = sessionFactory.createSession(); session.deleteQueue(subscriptionName); } catch (HornetQException e) { } finally { closeSession(session); } } }
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(); } }
protected void addPooled() throws HornetQException { ClientSession session = sessionFactory.createSession(); ClientProducer producer = session.createProducer(destination); session.start(); pool.add(new Pooled(session, producer)); }
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) { } } } } }
if (topic == null) ClientSession session = manager.getSessionFactory().createSession(false, false, false); try
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) { } } } }
protected void createSession() throws HornetQException { session = factory.createSession(true, true, 0); HornetQRestLogger.LOGGER.debug("Created session: " + session); if (selector == null) { consumer = session.createConsumer(destination); } else { consumer = session.createConsumer(destination, SelectorTranslator.convertToHornetQFilterString(selector)); } HornetQRestLogger.LOGGER.debug("Created consumer: " + consumer); session.start(); }
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()); }
_clientSession = _clientSessionFactory.createSession(_user, _passwd, false,
_clientSession = _clientSessionFactory.createSession(_user, _passwd, false,
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 addRegistration(PushTopicRegistration reg) throws Exception { if (reg.isEnabled() == false) return; String destination = reg.getDestination(); ClientSession session = sessionFactory.createSession(false, false, false); ClientSession.QueueQuery query = session.queueQuery(new SimpleString(destination)); ClientSession createSession = null; if (!query.isExists()) { createSession = createSubscription(destination, reg.isDurable()); } PushSubscription consumer = new PushSubscription(sessionFactory, reg.getDestination(), reg.getId(), reg, pushStore); try { consumer.start(); } catch (Exception e) { consumer.stop(); throw new Exception("Failed starting push subscriber for " + destination + " of push subscriber: " + reg.getTarget(), e); } finally { closeSession(createSession); closeSession(session); } consumers.put(reg.getId(), consumer); }
/** * creates IOFog message queues, {@link ClientMessage} producer * and {@link ClientSession} * * @throws Exception */ void initialize() throws Exception { synchronized (messageBusSessionLock) { messageBusSession = sf.createSession(true, true, 0); QueueQuery queueQuery = messageBusSession.queueQuery(new SimpleString(Constants.ADDRESS)); if (queueQuery.isExists()) messageBusSession.deleteQueue(Constants.ADDRESS); queueQuery = messageBusSession.queueQuery(new SimpleString(Constants.COMMAND_LINE_ADDRESS)); if (queueQuery.isExists()) messageBusSession.deleteQueue(Constants.COMMAND_LINE_ADDRESS); messageBusSession.createQueue(Constants.ADDRESS, Constants.ADDRESS, false); messageBusSession.createQueue(Constants.COMMAND_LINE_ADDRESS, Constants.COMMAND_LINE_ADDRESS, false); commandlineProducer = messageBusSession.createProducer(Constants.COMMAND_LINE_ADDRESS); commandlineConsumer = messageBusSession.createConsumer(Constants.COMMAND_LINE_ADDRESS, String.format("receiver = '%s'", "iofog.commandline.command")); commandlineConsumer.setMessageHandler(new CommandLineHandler()); messageBusSession.start(); } }