public QueueConsumer createAcknowledgedConsumer(String selector) throws ActiveMQException { String genId = sessionCounter.getAndIncrement() + "-queue-" + destination + "-" + startup; QueueConsumer consumer = new AcknowledgedQueueConsumer(sessionFactory, destination, genId, serviceManager, selector); addConsumer(consumer); return consumer; }
@Path("attributes-{attributes}/{consumer-id}") @GET public Response getConsumer(@PathParam("attributes") int attributes, @PathParam("consumer-id") String consumerId, @Context UriInfo uriInfo) throws Exception { ActiveMQRestLogger.LOGGER.debug("Handling GET request for \"" + uriInfo.getPath() + "\""); return headConsumer(attributes, consumerId, uriInfo); }
queueResource.setServiceManager(manager); ConsumersResource consumers = new ConsumersResource(); consumers.setConsumerTimeoutSeconds(timeoutSeconds); consumers.setDestination(queueName); consumers.setSessionFactory(manager.getConsumerSessionFactory()); consumers.setServiceManager(manager); queueResource.setConsumers(consumers);
consumer = createConsumer(selector); } else { attributes |= ACKNOWLEDGED; consumer = createAcknowledgedConsumer(selector);
@Path("attributes-{attributes}/{consumer-id}") public QueueConsumer findConsumer(@PathParam("attributes") int attributes, @PathParam("consumer-id") String consumerId, @Context UriInfo uriInfo) throws Exception { QueueConsumer consumer = queueConsumers.get(consumerId); if (consumer == null) { if ((attributes & SELECTOR_SET) > 0) { Response.ResponseBuilder builder = Response.status(Response.Status.GONE).entity("Cannot reconnect to selector-based consumer. You must recreate the consumer session.").type("text/plain"); UriBuilder uriBuilder = uriInfo.getBaseUriBuilder(); uriBuilder.path(uriInfo.getMatchedURIs().get(1)); serviceManager.getLinkStrategy().setLinkHeader(builder, "pull-consumers", "pull-consumers", uriBuilder.build().toString(), null); throw new WebApplicationException(builder.build()); } if ((attributes & ACKNOWLEDGED) > 0) { QueueConsumer tmp = new AcknowledgedQueueConsumer(sessionFactory, destination, consumerId, serviceManager, null); consumer = addReconnectedConsumerToMap(consumerId, tmp); } else { QueueConsumer tmp = new QueueConsumer(sessionFactory, destination, consumerId, serviceManager, null); consumer = addReconnectedConsumerToMap(consumerId, tmp); } } return consumer; }
@Path("attributes-{attributes}/{consumer-id}") @HEAD public Response headConsumer(@PathParam("attributes") int attributes, @PathParam("consumer-id") String consumerId, @Context UriInfo uriInfo) throws Exception { ActiveMQRestLogger.LOGGER.debug("Handling HEAD request for \"" + uriInfo.getPath() + "\""); QueueConsumer consumer = findConsumer(attributes, consumerId, uriInfo); Response.ResponseBuilder builder = Response.noContent(); // we synchronize just in case a failed request is still processing synchronized (consumer) { if ((attributes & ACKNOWLEDGED) > 0) { AcknowledgedQueueConsumer ackedConsumer = (AcknowledgedQueueConsumer) consumer; Acknowledgement ack = ackedConsumer.getAck(); if (ack == null || ack.wasSet()) { AcknowledgedQueueConsumer.setAcknowledgeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId(), Long.toString(consumer.getConsumeIndex())); } else { ackedConsumer.setAcknowledgementLink(builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId()); } } else { QueueConsumer.setConsumeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId(), Long.toString(consumer.getConsumeIndex())); } } return builder.build(); }
queueResource.setServiceManager(manager); ConsumersResource consumers = new ConsumersResource(); consumers.setConsumerTimeoutSeconds(timeoutSeconds); consumers.setDestination(queueName); consumers.setSessionFactory(manager.getConsumerSessionFactory()); consumers.setServiceManager(manager); queueResource.setConsumers(consumers);
consumer = createConsumer(selector); } else { attributes |= ACKNOWLEDGED; consumer = createAcknowledgedConsumer(selector);
@Path("attributes-{attributes}/{consumer-id}") public QueueConsumer findConsumer(@PathParam("attributes") int attributes, @PathParam("consumer-id") String consumerId, @Context UriInfo uriInfo) throws Exception { QueueConsumer consumer = queueConsumers.get(consumerId); if (consumer == null) { if ((attributes & SELECTOR_SET) > 0) { Response.ResponseBuilder builder = Response.status(Response.Status.GONE).entity("Cannot reconnect to selector-based consumer. You must recreate the consumer session.").type("text/plain"); UriBuilder uriBuilder = uriInfo.getBaseUriBuilder(); uriBuilder.path(uriInfo.getMatchedURIs().get(1)); serviceManager.getLinkStrategy().setLinkHeader(builder, "pull-consumers", "pull-consumers", uriBuilder.build().toString(), null); throw new WebApplicationException(builder.build()); } if ((attributes & ACKNOWLEDGED) > 0) { QueueConsumer tmp = new AcknowledgedQueueConsumer(sessionFactory, destination, consumerId, serviceManager, null); consumer = addReconnectedConsumerToMap(consumerId, tmp); } else { QueueConsumer tmp = new QueueConsumer(sessionFactory, destination, consumerId, serviceManager, null); consumer = addReconnectedConsumerToMap(consumerId, tmp); } } return consumer; }
@Path("attributes-{attributes}/{consumer-id}") @HEAD public Response headConsumer(@PathParam("attributes") int attributes, @PathParam("consumer-id") String consumerId, @Context UriInfo uriInfo) throws Exception { ActiveMQRestLogger.LOGGER.debug("Handling HEAD request for \"" + uriInfo.getPath() + "\""); QueueConsumer consumer = findConsumer(attributes, consumerId, uriInfo); Response.ResponseBuilder builder = Response.noContent(); // we synchronize just in case a failed request is still processing synchronized (consumer) { if ((attributes & ACKNOWLEDGED) > 0) { AcknowledgedQueueConsumer ackedConsumer = (AcknowledgedQueueConsumer) consumer; Acknowledgement ack = ackedConsumer.getAck(); if (ack == null || ack.wasSet()) { AcknowledgedQueueConsumer.setAcknowledgeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId(), Long.toString(consumer.getConsumeIndex())); } else { ackedConsumer.setAcknowledgementLink(builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId()); } } else { QueueConsumer.setConsumeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId(), Long.toString(consumer.getConsumeIndex())); } } return builder.build(); }
public QueueConsumer createConsumer(String selector) throws ActiveMQException { String genId = sessionCounter.getAndIncrement() + "-queue-" + destination + "-" + startup; QueueConsumer consumer = new QueueConsumer(sessionFactory, destination, genId, serviceManager, selector); addConsumer(consumer); return consumer; }
@Path("attributes-{attributes}/{consumer-id}") @GET public Response getConsumer(@PathParam("attributes") int attributes, @PathParam("consumer-id") String consumerId, @Context UriInfo uriInfo) throws Exception { ActiveMQRestLogger.LOGGER.debug("Handling GET request for \"" + uriInfo.getPath() + "\""); return headConsumer(attributes, consumerId, uriInfo); }
public QueueConsumer createAcknowledgedConsumer(String selector) throws ActiveMQException { String genId = sessionCounter.getAndIncrement() + "-queue-" + destination + "-" + startup; QueueConsumer consumer = new AcknowledgedQueueConsumer(sessionFactory, destination, genId, serviceManager, selector); addConsumer(consumer); return consumer; }
public QueueConsumer createConsumer(String selector) throws ActiveMQException { String genId = sessionCounter.getAndIncrement() + "-queue-" + destination + "-" + startup; QueueConsumer consumer = new QueueConsumer(sessionFactory, destination, genId, serviceManager, selector); addConsumer(consumer); return consumer; }