I have setup an application with jhisper gateway with one microservice in REST linked to Web3j. Idea is when you store an object in the database, you notarize it in a private ethereum blockchain.

So, I have a REST Post service to create the object in database, then he call a smartcontract to notarize it in the blockchain. Everything is working for One object at a time but if I make a loop without wait method, it will create in the blockchain only the first one. Like it didn't call it several time...

when I look to the log of the miner (txpool.status)

  pending: 1,
  queued: 0

I have never more than 1 in pending, such as he did 'nt see the 100 other...

        List<Long> thingIds = new ArrayList<Long>();
    for(int i=0; i<10;i++) {
        ApiClient apiClient = new ApiClient();
        HttpBasicAuth authentication = (HttpBasicAuth)apiClient.getAuthentications().get("basic");
        Date d = new Date();
        String a= ""+d.getTime();

        ThingResourceApi agentResourceApi = new ThingResourceApi(apiClient);
        thing = new Thing();
        thing.setName("Paris"+(new Date().getTime()));

        thing = agentResourceApi.createThingUsingPOST(thing);

if i add the following snipped at the end of the loop, it works

try {
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block

I am sorry if it is a little confusing, hope you will have an interest to give me idea to solve it...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.