Another of the features I wanted to improve for my Bittrex project was to create a better system for sending requests to the HTTP API servers. Because of their rate limit, I couldn't just send requests for data whenever I needed it. Ideally, I want to get market ticks every minute as that's when they update. There are around 90 Bitcoin markets, though, which would mean 90 requests every minute. This would lead to Bittrex temporarily blocking my requests.
On top of market tick requests, I also make requests for order data, as well as requests to place orders. If I sent them immediately, I could easily accidentally send five at once and get blocked. Instead, I used a queue with a callback feature.
Callbacks are usually anonymous classes which let you run code at a future data. You run the function, say getOrders(), and supply it with a function that will be run when the request goes through. The HTTP manager class collects requests in a list, and executes them in order with a one second delay, and returning the data or throwing an exception if required.