PDA

View Full Version : Spring Integration 2.x REST Service Call Question



TimWhite
Nov 13th, 2009, 11:22 AM
So, I'm working on learning Spring Integration, and I'm hacking on the "quote" example.

What I'd like to do is create a new version of the QuoteService that gets a real quote for a ticker.

So, I built this:


@MessageEndpoint
public class QuoteService {

@ServiceActivator(inputChannel = "tickers", outputChannel = "quotes")
public Quote lookupQuote(String ticker) {
String result = null;
try {
URL yahooUrl = new URL("http://finance.yahoo.com/d/quotes.csv?f=l1&s=" + ticker);

BufferedReader in = new BufferedReader(new InputStreamReader(yahooUrl.openStream()));

result = in.readLine();

in.close();
} catch (IOException e) {
e.printStackTrace();
}

return (new Quote(ticker, new BigDecimal(result)));

}

But I'd like to handle the call to the Yahoo service with Spring Integration, rather than having QuoteService have to be a class that invokes it explicitly. I see in the "ws" example how I might explicitly invoke a ws-style call, but I'm looking for an annotation-driven/bean driven way to do it, rather than using the Message API directly.

I am just not quite getting what I could use that would let me adjust the URL parameters to include the input from the previous item in the chain.

Any help would be appreciated!

Thanks,

Tim