Package org.hornetq.api.core.client

Examples of org.hornetq.api.core.client.ClientSession


      this.pushStore = pushStore;
   }

   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)
      {
View Full Code Here


   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);
View Full Code Here

      {
         registration.setDestination(genId);
      }
      registration.setId(genId);
      registration.setTopic(destination);
      ClientSession createSession = createSubscription(genId, registration.isDurable());
      try
      {
         PushSubscription consumer = new PushSubscription(sessionFactory, genId, genId, registration, pushStore);
         try
         {
View Full Code Here

   }

   private void deleteSubscriberQueue(PushConsumer consumer)
   {
      String subscriptionName = consumer.getDestination();
      ClientSession session = null;
      try
      {
         session = sessionFactory.createSession();

         session.deleteQueue(subscriptionName);
      }
      catch (HornetQException e)
      {
      }
      finally
View Full Code Here

   }

   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)
         {
         }
      }
View Full Code Here

      }
      else
      {
         subscriptionName = generateSubscriptionName();
      }
      ClientSession session = null;
      try
      {
         // if this is not a reconnect, create the subscription queue
         if (!subscriptionExists(subscriptionName))
         {
            session = sessionFactory.createSession();

            if (durable)
            {
               session.createQueue(destination, subscriptionName, true);
            }
            else
            {
               session.createTemporaryQueue(destination, subscriptionName);
            }
         }
         QueueConsumer consumer = createConsumer(durable, autoAck, subscriptionName, selector, timeout, deleteWhenIdle);
         queueConsumers.put(consumer.getId(), consumer);
         serviceManager.getTimeoutTask().add(this, consumer.getId());

         UriBuilder location = uriInfo.getAbsolutePathBuilder();
         if (autoAck) location.path("auto-ack");
         else location.path("acknowledged");
         location.path(consumer.getId());
         Response.ResponseBuilder builder = Response.created(location.build());
         if (autoAck)
         {
            QueueConsumer.setConsumeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/auto-ack/" + consumer.getId(), "-1");
         }
         else
         {
            AcknowledgedQueueConsumer.setAcknowledgeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/acknowledged/" + consumer.getId(), "-1");

         }
         return builder.build();

      }
      catch (HornetQException e)
      {
         throw new RuntimeException(e);
      }
      finally
      {
         if (session != null)
         {
            try
            {
               session.close();
            }
            catch (HornetQException e)
            {
            }
         }
View Full Code Here

      return consumer;
   }

   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)
            {
            }
         }
View Full Code Here

   {
      // we close current session so that message is redelivered
      // for temporary queues/topics, create a new session before closing old so we don't lose the temporary topic/queue

      ClientConsumer old = consumer;
      ClientSession oldSession = session;

      try
      {
         createSession();
      }
      catch (Exception e)
      {
         shutdown();
         throw new RuntimeException(e);

      }
      finally
      {
         try
         {
            old.close();
         }
         catch (HornetQException e)
         {
         }
         try
         {
            oldSession.close();
         }
         catch (HornetQException e)
         {
         }
      }
View Full Code Here

   }

   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)
            {
            }
         }
View Full Code Here

   }

   protected void addPooled()
           throws HornetQException
   {
      ClientSession session = sessionFactory.createSession();
      ClientProducer producer = session.createProducer(destination);
      session.start();
      pool.add(new Pooled(session, producer));
   }
View Full Code Here

TOP

Related Classes of org.hornetq.api.core.client.ClientSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.