Examples of QueueConsumer


Examples of co.cask.cdap.data2.queue.QueueConsumer

  @Override
  public StreamConsumer create(QueueName streamName, String namespace,
                               ConsumerConfig consumerConfig) throws IOException {

    QueueConsumer consumer = queueClientFactory.createConsumer(streamName, consumerConfig, -1);
    return new QueueToStreamConsumer(streamName, consumerConfig, consumer);
  }
View Full Code Here

Examples of co.cask.tigon.data.queue.QueueConsumer

  }

  @Override
  public QueueConsumer createConsumer(QueueName queueName,
                                       ConsumerConfig consumerConfig, int numGroups) throws IOException {
    QueueConsumer consumer = queueClientFactory.createConsumer(queueName, consumerConfig, numGroups);
    if (consumer instanceof TransactionAware) {
      consumer = new CloseableQueueConsumer(this, consumer);
      txAware.add((TransactionAware) consumer);
    }
    return consumer;
View Full Code Here

Examples of co.cask.tigon.data.queue.QueueConsumer

    };
  }

  @Override
  public InputDatum<T> tryDequeue(long timeout, TimeUnit timeoutUnit) throws IOException {
    QueueConsumer consumer = consumerSupplier.get();
    return new BasicInputDatum<byte[], T>(consumer.getQueueName(), consumer.dequeue(batchSize), decoder);
  }
View Full Code Here

Examples of co.cask.tigon.data.queue.QueueConsumer

                                    groupSize,
                                    consumerConfig.getDequeueStrategy(),
                                    consumerConfig.getHashKey());
      }
      if (queueName.isQueue()) {
        QueueConsumer queueConsumer = dataFabricFacade.createConsumer(queueName, config, numGroups);
        consumerConfig = queueConsumer.getConfig();
        consumer = queueConsumer;
      }
    } catch (Exception e) {
      throw Throwables.propagate(e);
    }
View Full Code Here

Examples of org.apache.qpid.server.queue.QueueConsumer

            {
                boolean acquired = messageInstance.acquire();
                if(!acquired && messageInstance instanceof QueueEntry)
                {
                    QueueEntry entry = (QueueEntry) messageInstance;
                    QueueConsumer consumer = (QueueConsumer) entry.getDeliveredConsumer();
                    acquired = messageInstance.removeAcquisitionFromConsumer(consumer);
                    if(acquired)
                    {
                        consumer.acquisitionRemoved((QueueEntry)messageInstance);
                    }
                }
                if(acquired)
                {
                    txn.dequeue(messageInstance.getOwningResource(), messageInstance.getMessage(), new ServerTransaction.Action()
View Full Code Here

Examples of org.hornetq.rest.queue.QueueConsumer

      this.destination = destination;
   }

   public boolean testTimeout(String target, boolean autoShutdown)
   {
      QueueConsumer consumer = queueConsumers.get(target);
      Subscription subscription = (Subscription)consumer;
      if (consumer == null) return false;
      if (System.currentTimeMillis() - consumer.getLastPingTime() > subscription.getTimeout())
      {
         HornetQRestLogger.LOGGER.shutdownRestSubscription(consumer.getId());
         if(autoShutdown)
         {
            shutdown(consumer);
         }
         return true;
View Full Code Here

Examples of org.hornetq.rest.queue.QueueConsumer

      }
   }

   public void shutdown(String target)
   {
      QueueConsumer consumer = queueConsumers.get(target);
      if (consumer == null) return;
      shutdown(consumer);
   }
View Full Code Here

Examples of org.hornetq.rest.queue.QueueConsumer

      if (destroyWhenIdle != null) deleteWhenIdle = destroyWhenIdle.booleanValue();

      if (subscriptionName != null)
      {
         // see if this is a reconnect
         QueueConsumer consumer = queueConsumers.get(subscriptionName);
         if (consumer != null)
         {
            boolean acked = consumer instanceof AcknowledgedSubscriptionResource;
            acked = !acked;
            if (acked != autoAck)
            {
               throw new WebApplicationException(
                       Response.status(412).entity("Consumer already exists and ack-modes don't match.").type("text/plain").build()
               );
            }
            Subscription sub = (Subscription) consumer;
            if (sub.isDurable() != durable)
            {
               throw new WebApplicationException(
                       Response.status(412).entity("Consumer already exists and durability doesn't match.").type("text/plain").build()
               );
            }
            Response.ResponseBuilder builder = Response.noContent();
            if (autoAck)
            {
               headAutoAckSubscriptionResponse(uriInfo, consumer, builder);
               consumer.setSessionLink(builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/auto-ack/" + consumer.getId());
            }
            else
            {
               headAcknowledgedConsumerResponse(uriInfo, (AcknowledgedQueueConsumer) consumer, builder);
               consumer.setSessionLink(builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/acknowledged/" + consumer.getId());
            }
            return builder.build();
         }
      }
      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();

      }
View Full Code Here

Examples of org.hornetq.rest.queue.QueueConsumer

   }

   protected QueueConsumer createConsumer(boolean durable, boolean autoAck, String subscriptionName, String selector, long timeout, boolean deleteWhenIdle)
           throws HornetQException
   {
      QueueConsumer consumer;
      if (autoAck)
      {
         SubscriptionResource subscription = new SubscriptionResource(sessionFactory, subscriptionName, subscriptionName, serviceManager, selector, durable, timeout);
         subscription.setDurable(durable);
         subscription.setDeleteWhenIdle(deleteWhenIdle);
View Full Code Here

Examples of org.hornetq.rest.queue.QueueConsumer

      return internalHeadAutoAckSubscription(uriInfo, consumerId);
   }

   private Response internalHeadAutoAckSubscription(UriInfo uriInfo, String consumerId)
   {
       QueueConsumer consumer = findAutoAckSubscription(consumerId);
       Response.ResponseBuilder builder = Response.noContent();
       headAutoAckSubscriptionResponse(uriInfo, consumer, builder);

       return builder.build();
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.