public Messages reserve ( int numberOfMessages , int timeout , int wait ) throws IOException { if ( numberOfMessages < 1 || numberOfMessages > 100 ) { throw new IllegalArgumentException ( "numberOfMessages has to be within 1..100" ) ; } MessagesReservationModel payload = new MessagesReservationModel ( numberOfMessages , timeout , wait ) ; String url = "queues/" + name + "/reservations" ; IronReader reader = client . post ( url , gson . toJson ( payload ) ) ; Messages messages = gson . fromJson ( reader . reader , Messages . class ) ; reader . close ( ) ; return messages ; }
Retrieves Messages from the queue and reserves it . If there are no items on the queue an EmptyQueueException is thrown .