...
For more info, take a look at RestTest
Consuming with One Shot Consumers
One shot consumption allows a REST call to receive a single message and then immediately close the associated consumer.
All of the examples so far lead to the servlet creating and holding on to consumers of the destination across multiple HTTP requests. Without care, these consumers could easily lead to confusion as messages are dispatched to them but then sit unused because the consuming HTTP session, or clientId, fails to connect to continue requesting the messages. One way around that problem is the use of one-shot consumers. Simple add the ?_oneShot_=true option and the consumer is removed once the consumption completes; as follows:
Code Block |
curl -XGET http://admin:admin@localhost:8161/api/message?destination=queue://orders.input&_oneShot_=true
|
Note that interrupting the call while the consumer is waiting for a message, the consumer may remain until the server times out the HTTP request, or until a message finally arrives.
Content Types
By default messages are sent to the consumers with text/xml content type. Your REST-based application may expect JSON response instead of XML one. In that case, you can configure the servlet to send responses back by adding something like this
...