@Override Status execute() { Status status = new Status(); try { // replace now reference with the specified date now = DateTime.parse(today).withTimeAtStartOfDay(); } catch (Exception ignored) {} // extract monthly, quarterly, half-yearly and yearly list of resellers from the schedule if (!extractSchedule(schedule)) status.setClientError("Invalid request, nothing to process"); else { // monthly, quarterly, half-yearly and yearly bill requests List<GenerateBillRun> requests = getBillRequests(); if (requests == null) { status.setServerError("Couldn't generate list of Bill Request commands"); } else if (requests.isEmpty()) { status.setSuccessful("Nothing to generate for today"); } else { RoutingKey key = Loader.extractProperties(RoutingKey.class); for (Command command: requests) { if (!Messenger.publish(command, key.getPublishToSelf())) { status.setServerError("Couldn't publish one of generated commands to the RabbitMQ"); return status; } } status.setSuccessful(String.format("Created and published %d Bill Request commands", requests.size())); } } return status; }
Credentials credentials = Loader.extractProperties(Credentials.class); if (credentials == null || !credentials.isValid()) { status.setServerError("Missing Customer DB credentials"); RoutingKey key = Loader.extractProperties(RoutingKey.class); for (Command command: commands) { if (!Messenger.publish(command, key.getPublishToSelf())) {
Credentials credentials = Loader.extractProperties(Credentials.class); if (credentials == null || !credentials.isValid()) { status.setServerError("Missing Customer DB credentials"); RoutingKey key = Loader.extractProperties(RoutingKey.class); for (Command command: commands) { if (!Messenger.publish(command, key.getPublishToSelf())) {
@Override Status execute() { Status status = new Status(); // sanity checks first if (time_from == null || time_to == null || time_from < 0L || time_to < time_from) { status.setClientError("Invalid FROM and TO (unit to be in milliseconds)"); return status; } try { // validate request and get list of records List<String> accounts = validateRequestBody(request); // request CDR to flush data for these accounts FlushCDRs flushCDRs = new FlushCDRs(time_from, time_to, accounts); BillRequest billRequest = new BillRequest(time_from, time_to, accounts, request); // extract routing keys from the configuration file RoutingKeys keys = Loader.extractProperties(RoutingKeys.class); // and also forward this request to CoinBill if (Messenger.publish(flushCDRs, keys.getPublishToCDRWithKey()) && Messenger.publish(billRequest, keys.getPublishToCoinBillWithKey())) status.setSuccessful(String.format("GenerateBill request processed for %d - %d", time_from, time_to)); else status.setServerError(String.format("GenerateBill unable to notify CDR and CoinBill for %d - %d due to RabbitMQ", time_from, time_to)); } catch (Exception e) { status.setClientError(e.getMessage()); } return status; }
@Override Status execute() { Status status = new Status(); // sanity checks first if (time_from == null || time_to == null || time_from < 0L || time_to < time_from) { status.setClientError("Invalid FROM and TO (unit to be in milliseconds)"); return status; } try { // validate request and get list of records List<String> accounts = validateRequestBody(request); // request CDR to flush data for these accounts FlushCDRs flushCDRs = new FlushCDRs(time_from, time_to, run, accounts); BillRequest billRequest = new BillRequest(time_from, time_to, run, accounts, request); // extract routing keys from the configuration file RoutingKeys keys = Loader.extractProperties(RoutingKeys.class); // and also forward this request to CoinBill if (Messenger.publish(flushCDRs, keys.getPublishToCDRWithKey()) && Messenger.publish(billRequest, keys.getPublishToCoinBillWithKey())) status.setSuccessful(String.format("GenerateBill request processed for %d - %d", time_from, time_to)); else status.setServerError(String.format("GenerateBill unable to notify CDR and CoinBill for %d - %d due to RabbitMQ", time_from, time_to)); } catch (Exception e) { status.setClientError(e.getMessage()); } return status; }