I'm curious, why would you use the REST API from a Java client rather than using the Java-native JMS API, which doesn't have edge cases such as the need to keep the connection alive and the challenges with messages getting stranded in prefetch buffers?
Tim On Wed, Jul 10, 2019, 10:27 AM Luigi Suardi <lsua...@sorint.it> wrote: > hello activemq, > > i am using amq 5.15.9 and want to consume messages using the REST API. i > am hitting the issue described in the documentation @ > https://activemq.apache.org/rest > > "When consuming messages using the REST API, you have to keep session > alive between GET requests, or you’ll create a separate consumer for > every request and due to prefetch limit your succeeding call will hang." > > I wrote my consumer in Java 8 using > org.springframework.web.client.RestTemplate > > HttpHeaders headers = new HttpHeaders(); > headers.set("Authorization", getAuthorizationHeader()); > headers.set("Connection", "Keep-Alive"); > > HttpEntity<String> request = new HttpEntity<String>("", headers); > > ResponseEntity<String> response = > restTemplate.exchange( > "http://localhost:8161/api/message/quote?type=queue", > HttpMethod.GET, > request, > String.class); > > and getting a successful consume on first request and hanging request > from then on with 204 response after a long wait... > > can someone please share an example of working Java consumer using the > REST API? I does not matter if based on RestTemplate or other tool for > HTTP client requests. > > Thanks much in advance. > Luigi > > > > > >