Slide 28
Slide 28 text
public class GetSessionHystrixCommand extends ConfigurableHystrixCommand {
private static Logger log = LoggerFactory.getLogger(GetSessionHystrixCommand.class);
private final String sessionId;
private final GetSessionCommand getSessionCommand;
public GetSessionHystrixCommand(String id, RestExecutionContext context, CommandSettings settings) {
super(XAP_SESSION_COMMAND, settings);
this.sessionId = id;
this.getSessionCommand = new GetSessionCommand(id, context);
}
@Override
protected XapSession run() throws Exception {
try {
return getSessionCommand.execute();
} catch (Exception exception) {
log.error("Failed to get session", exception);
throw exception;
}
}
@Override
protected ExpiringSession getFallback() {
log.error("Falling back on getting session due to {}", getExecutionEvents());
return FailoverSession.create(sessionId);
}
}
production code