Example usage for org.springframework.amqp.rabbit.stocks.domain Quote getTimestamp

List of usage examples for org.springframework.amqp.rabbit.stocks.domain Quote getTimestamp

Introduction

In this page you can find the example usage for org.springframework.amqp.rabbit.stocks.domain Quote getTimestamp.

Prototype

public long getTimestamp() 

Source Link

Usage

From source file:org.springframework.amqp.rabbit.stocks.web.QuoteController.java

public void handleQuote(Quote message) {
    logger.info("Client received: " + message);
    long timestamp = System.currentTimeMillis() - timeout;
    for (Iterator<Quote> iterator = quotes.iterator(); iterator.hasNext();) {
        Quote quote = iterator.next();
        if (quote.getTimestamp() < timestamp) {
            iterator.remove();//  ww w . j a  va  2 s .  c  om
        }
    }
    quotes.add(message);
}

From source file:org.springframework.amqp.rabbit.stocks.web.QuoteController.java

@RequestMapping("/quotes")
@ResponseBody//from  w ww  . j  a v  a2  s  .  c o m
public List<Quote> quotes(@RequestParam(required = false) Long timestamp) {
    if (timestamp == null) {
        timestamp = 0L;
    }
    ArrayList<Quote> list = new ArrayList<Quote>();
    for (Quote quote : quotes) {
        if (quote.getTimestamp() > timestamp) {
            list.add(quote);
        }
    }
    Collections.reverse(list);
    return list;
}