org.apache.activemq.artemis.rest.queue.QueueConsumer

Here are the examples of the java api class org.apache.activemq.artemis.rest.queue.QueueConsumer taken from open source projects.

1. SubscriptionsResource#testTimeout()

View license
@Override
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()) {
        ActiveMQRestLogger.LOGGER.shutdownRestSubscription(consumer.getId());
        if (autoShutdown) {
            shutdown(consumer);
        }
        return true;
    } else {
        return false;
    }
}

2. SubscriptionsResource#createConsumer()

View license
protected QueueConsumer createConsumer(boolean durable, boolean autoAck, String subscriptionName, String selector, long timeout, boolean deleteWhenIdle) throws ActiveMQException {
    QueueConsumer consumer;
    if (autoAck) {
        SubscriptionResource subscription = new SubscriptionResource(sessionFactory, subscriptionName, subscriptionName, serviceManager, selector, durable, timeout);
        subscription.setDurable(durable);
        subscription.setDeleteWhenIdle(deleteWhenIdle);
        consumer = subscription;
    } else {
        AcknowledgedSubscriptionResource subscription = new AcknowledgedSubscriptionResource(sessionFactory, subscriptionName, subscriptionName, serviceManager, selector, durable, timeout);
        subscription.setDurable(durable);
        subscription.setDeleteWhenIdle(deleteWhenIdle);
        consumer = subscription;
    }
    return consumer;
}

3. SubscriptionsResource#recreateTopicConsumer()

View license
private QueueConsumer recreateTopicConsumer(String subscriptionId, boolean autoAck) {
    QueueConsumer consumer;
    if (subscriptionExists(subscriptionId)) {
        QueueConsumer tmp = null;
        try {
            tmp = createConsumer(true, autoAck, subscriptionId, null, consumerTimeoutSeconds * 1000, false);
        } catch (ActiveMQException e) {
            throw new RuntimeException(e);
        }
        consumer = queueConsumers.putIfAbsent(subscriptionId, tmp);
        if (consumer == null) {
            consumer = tmp;
            serviceManager.getTimeoutTask().add(this, subscriptionId);
        } else {
            tmp.shutdown();
        }
    } else {
        throw new WebApplicationException(Response.status(405).entity("Failed to find subscriber " + subscriptionId + " you will have to reconnect").type("text/plain").build());
    }
    return consumer;
}

4. SubscriptionsResource#internalDeleteSubscription()

View license
private void internalDeleteSubscription(String consumerId) {
    QueueConsumer consumer = queueConsumers.remove(consumerId);
    if (consumer == null) {
        String msg = "Failed to match a subscription to URL " + consumerId;
        throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).entity(msg).type("text/plain").build());
    }
    consumer.shutdown();
    deleteSubscriberQueue(consumer);
}

5. SubscriptionsResource#shutdown()

View license
@Override
public void shutdown(String target) {
    QueueConsumer consumer = queueConsumers.get(target);
    if (consumer == null)
        return;
    shutdown(consumer);
}

6. SubscriptionsResource#stop()

View license
public void stop() {
    for (QueueConsumer consumer : queueConsumers.values()) {
        consumer.shutdown();
        Subscription subscription = (Subscription) consumer;
        if (!subscription.isDurable()) {
            deleteSubscriberQueue(consumer);
        }
    }
    queueConsumers.clear();
}

7. SubscriptionsResource#internalHeadAutoAckSubscription()

View license
private Response internalHeadAutoAckSubscription(UriInfo uriInfo, String consumerId) {
    QueueConsumer consumer = findAutoAckSubscription(consumerId);
    Response.ResponseBuilder builder = Response.noContent();
    String pathToPullSubscriptions = uriInfo.getMatchedURIs().get(1);
    headAutoAckSubscriptionResponse(uriInfo, consumer, builder, pathToPullSubscriptions);
    return builder.build();
}

8. SubscriptionsResource#findAutoAckSubscription()

View license
@Path("auto-ack/{subscription-id}")
public QueueConsumer findAutoAckSubscription(@PathParam("subscription-id") String subscriptionId) {
    QueueConsumer consumer = queueConsumers.get(subscriptionId);
    if (consumer == null) {
        consumer = recreateTopicConsumer(subscriptionId, true);
    }
    return consumer;
}

9. SubscriptionsResource#findAcknoledgeSubscription()

View license
@Path("acknowledged/{subscription-id}")
public QueueConsumer findAcknoledgeSubscription(@PathParam("subscription-id") String subscriptionId) {
    QueueConsumer consumer = queueConsumers.get(subscriptionId);
    if (consumer == null) {
        consumer = recreateTopicConsumer(subscriptionId, false);
    }
    return consumer;
}