[prev in list] [next in list] [prev in thread] [next in thread] 

List:       activemq-users
Subject:    Re: consuming messages with REST API in Java
From:       Luigi Suardi <lsuardi () sorint ! it>
Date:       2019-07-12 19:19:17
Message-ID: 4e399793-d4c1-08bc-8e66-9c27690b4928 () sorint ! it
[Download RAW message or body]

AMQ would be one of many microservices in our service oriented (hybrid 
cloud) architecture... all communication is REST / HTTP based with API 
gateways and other tools used to route, balance and control access to 
API end points... I am not sure how to fit JMS in this scenario.

Thoughts?

Luigi



On 7/11/2019 2:41 PM, Tim Bain wrote:
> 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 <lsuardi@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
>>
>>
>>
>>
>>
>>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic