-
Notifications
You must be signed in to change notification settings - Fork 37
Output Buffered
This code makes a HTTP request to get the last 'n' JSONP data from a REDIS DB to a client using a servlet. After sending the data, it closes the connection. The data from the REDIS channels is buffered in the background by a continuous running buffering system - started at servlet startup. The jsonp messages are returned in an ArrayList data structure, in reverse chronological order.
The code accepts i) channel name or, ii) fully qualified channel name. However, wildcard '*' for pattern based subscription are NOT allowed.
Hints for testing:
- Tune the socket timeout parameter in JedisPool(...) call if connecting over a slow network
- Tune REDIS_CALLBACK_TIMEOUT, in case the rate of publication is very slow
- Tune the number of threads in ExecutorService
Deployment steps:
- [Required] Set redisHost and redisPort in code, as per your REDIS setup/location
- [Optional] Tune time-out and other parameters, if necessary
- [Required]Compile and package as WAR file
- [Required] Deploy as WAR file in glassfish 3.1.2
- [Optional] Setup ssh tunneling (e.g. command: ssh tunneling:: ssh -f -L 1978:localhost:6379 scd1.qcri.org -N)
- Issue getLast request from client
Invocation: host:port/context-root/rest/crisis/fetch/channel/{crisisCode}?callback={callback}&count={count}
Channel name based examples:
- http://localhost:8080/aidr-output/rest/crisis/fetch/channel/clex_20131201?count=50
- http://localhost:8080/aidr-output/rest/crisis/fetch/channel/clex_20131201?callback=JSONP
- http://localhost:8080/aidr-output/rest/crisis/fetch/channel/clex_20131201?callback=JSONP&count=50
Fully qualified channel name based examples:
- http://localhost:8080/aidr-output/rest/crisis/fetch/channel/aidr_predict.clex_20131201?count=50
- http://localhost:8080/aidr-output/rest/crisis/fetch/channel/aidr_predict.clex_20131201?callback=func
- http://localhost:8080/aidr-output/rest/crisis/fetch/channel/aidr_predict.clex_20131201?callback=func&count=50
Apart from the above valid paths one can use:
- http://localhost:8080/aidr-output/rest/crisis/fetch/channels/list => returns list of active channels
- http://localhost:8080/aidr-output/rest/crisis/fetch/channels/latest => returns the latest tweet data from across all channels
Parameter explanations:
- crisisCode [mandatory]: the REDIS channel to which to subscribe
- callback [optional]: name of the callback function for JSONP data
- count [optional]: the specified number of messages that have been buffered by the service. If unspecified or <= 0 or larger than the MAX_MESSAGES_COUNT, the default number of messages are returned
- Home
- [What is AIDR?](AIDR Overview)
- The science behind AIDR
- [Operator's manual](AIDR Operator's Manual)
- [Public API documentation](API documentation)
- High-level overview
- Common
- DB Manager
- DTO standards
- Database schema
- Manager
- Manager API
- Collector
- Collector API
- Reconnect strategy
- Collector Tester
- Output
- Output API
- Output Buffered
- Output Streaming
- Output Tester
- Persister
- Persister API
- Persister Tester
- Tagger
- Tagger Concepts
- Tagger API
- Tagger Tester
- Trainer
- Trainer API
- PyBossa Trainer