Hi guys I have a processor which is working on a dataset containing Arraylist of Hashmaps which comes in the exchange body.
I get following exception. Any clue of why is this happening? I am not even modifying the datastructure :-( Its strange as each time I execute the program, the error happens with different records. Its very random. *[Camel (camel-1) thread #1 - vm://AllocationAmountPerShipment] ERROR org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-FWLYGZ1-59683-1452089290442-0-9086 on ExchangeId: ID-FWLYGZ1-59683-1452089290442-0-9707). Exhausted after delivery attempt: 1 caught: java.util.ConcurrentModificationException Message History --------------------------------------------------------------------------------------------------------------------------------------- RouteId ProcessorId Processor Elapsed (ms) [route3 ] [route3 ] [vm://AllocationAmountPerShipment?concurrentConsumers=1 ] [ 28] [route3 ] [process2 ] [ref:allocationAmountPerShipment ] [ 0] Exchange --------------------------------------------------------------------------------------------------------------------------------------- Exchange[ Id ID-FWLYGZ1-59683-1452089290442-0-9707 ExchangePattern InOnly Headers {breadcrumbId=ID-FWLYGZ1-59683-1452089290442-0-9086, CamelRedelivered=false, CamelRedeliveryCounter=0} BodyType java.util.ArrayList Body [{FRTB_I=442484055 , PROF_TYPE_C=LD , CARR_N=RUAN TRANSPORTATION PRIMARY ( , SCAC_C=LABR, VEND_I=4941410, * My code snipped for the processor is as follows * package com.processors; import org.apache.camel.*; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.impl.DefaultProducerTemplate; import java.util.List; import java.util.Map; /** * Created by Z001NLH on 1/6/2016. */ public class AllocationAmountPerShipmentImpl2 implements Processor{ @Override public void process(Exchange exchange) throws Exception { List<Map<String, Object>> shipmentsUnderSameFRTB_I = (List<Map<String, Object>>) exchange.getIn().getBody(); double total = 0.00; double individualShipmentWeight; double allocationAmountPerShipment; double TotalAmount = 0.00; int i = 0, j = 0; Map<String, Object> record = null; if (shipmentsUnderSameFRTB_I.size() < 1) { System.out.println("NULL RECORD SET"); } else { System.out.println("Dataset = "+shipmentsUnderSameFRTB_I.toString()); for (i = 0; i < shipmentsUnderSameFRTB_I.size(); i++) { //System.out.println("i is now "+i+" and size is "+shipmentsUnderSameFRTB_I.size()); total = total + Float.parseFloat(shipmentsUnderSameFRTB_I.get(i).get("SHIP_TOT_WT_Q").toString()); System.out.println("Total is now --" + total); } for (j = 0; j < shipmentsUnderSameFRTB_I.size(); j++) { System.out.println("j is now " + j + " and size is " + shipmentsUnderSameFRTB_I.size()); record = shipmentsUnderSameFRTB_I.get(j); individualShipmentWeight = Float.parseFloat(record.get("SHIP_TOT_WT_Q").toString()); TotalAmount = Double.parseDouble(record.get("APRO_A").toString()); System.out.println("Total Freight Weight =" + total); System.out.println("Individual Shipment Weight =" + individualShipmentWeight); System.out.println("Total Amount =" + TotalAmount); allocationAmountPerShipment = calculateAMPerShipment(individualShipmentWeight, total, TotalAmount); System.out.println("Allocation Amount for Item is " + allocationAmountPerShipment + " and total is " + TotalAmount + " FRTB_I is " + record.get("FRTB_I")); } } } static double calculateAMPerShipment(double SHIP_TOT_WT_Q,double total, double TotalFRGTAmount){ return (SHIP_TOT_WT_Q/total)*TotalFRGTAmount; } }* Cheers Reji ----- Reji Mathews Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB ) LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a Twitter - reji_mathews -- View this message in context: http://camel.465427.n5.nabble.com/Camel-processor-Handling-ArrayList-of-maps-tp5775893.html Sent from the Camel - Users mailing list archive at Nabble.com.