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)
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");
authentication.setBasePath("http://localhost:8080/");
authentication.setCredentials("admin","admin");
Date d = new Date();
String a= ""+d.getTime();
ThingResourceApi agentResourceApi = new ThingResourceApi(apiClient);
thing = new Thing();
thing.setName("Paris"+(new Date().getTime()));
thing.setCollectorAddress("0x3baeb8019a9cc9c488aa9355dc522e023a3b406d");
thing = agentResourceApi.createThingUsingPOST(thing);
thingIds.add(thing.getId());
}
if i add the following snipped at the end of the loop, it works
try {
TimeUnit.SECONDS.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I am sorry if it is a little confusing, hope you will have an interest to give me idea to solve it...
Francois