class InstrumentRepository {

    @Transactional
    public List<Instrument> update(List<Instrument> instruments, RequestInfo requestInfo) {

        InstrumentMapper mapper = new InstrumentMapper();

        if (persistThroughKafka != null && !persistThroughKafka.isEmpty()
                && persistThroughKafka.equalsIgnoreCase("yes")) {

            InstrumentRequest request = new InstrumentRequest();
            request.setRequestInfo(requestInfo);
            request.setInstruments(new ArrayList<>());

            for (Instrument iac : instruments)
                request.getInstruments().add(mapper.toContract(iac));

            instrumentQueueRepository.addToQue(request);

            return instruments;
        } else {

            List<Instrument> resultList = new ArrayList<Instrument>();

            for (Instrument iac : instruments)
                resultList.add(update(iac));

            InstrumentRequest request = new InstrumentRequest();
            request.setRequestInfo(requestInfo);
            request.setInstruments(new ArrayList<>());

            for (Instrument iac : resultList)
                request.getInstruments().add(mapper.toContract(iac));

            instrumentQueueRepository.addToSearchQue(request);

            return resultList;
        }

    }

    @Autowired public  InstrumentRepository(InstrumentJdbcRepository instrumentJdbcRepository,
            InstrumentQueueRepository instrumentQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            InstrumentESRepository instrumentESRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            InstrumentVoucherJdbcRepository instrumentVoucherJdbcRepository);

}