There are situations where we make an asynchronous request to get a list of entities (albums in the example). For each album we need to send another asynchronous request to get more detail about the entity, so that we can transofrm the entity with more detailed data. From the design point of view the cleanes solution is to hold all the logic needed for that process in a service, and the controller will ideally subscribe to a single observer that delivers the enriched entity (the original entity+ further details for the second data request).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example of error in processing a flux (with a map) stops the subscription (Only prints 1) | |
Flux.range(1,6) | |
.map(integer -> { | |
if(integer % 2 == 0) { | |
throw new RuntimeException("odd number!"); | |
} else { | |
return integer; | |
} | |
}) | |
.subscribe(flux -> flux.subscribe(System.out::println, System.err::println)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usage="boot <JAR file name> <start|stop|restart>" | |
startProcess() { | |
echo "Starting JAR ${jar_filename}" | |
process_pid=`pgrep -f "^java.*${jar_filename}"` | |
if [[ ${process_pid} ]] | |
then | |
echo "JAR is already running with PID ${process_pid}. Stop it before starting or restart it." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'oauth' | |
# api_key and api_secret values are got from the registration of your application in LinkedIn: | |
# http://developer.linkedin.com/ | |
api_key = 'Your API Key' | |
api_secret = 'Your API Secret' | |
# access_token and token_secret are known after the first execution code block | |
access_token = 'The token we get below' | |
token_secret = 'The token secret we get below' |