I have an aggregator that aggregates on size or completion interval.
For operational purposes, we want to log the aggregate size.

In the same route, we have both the following statements. (The first
statement was added for debuging.) However in the second statement when
accessing it via exchange.getIn().getHeader("CamelAggregatedSize",
Integer.class), I get a NPE bcos that header is missing. I'm wondering what
I'm missing ?

.log(LoggingLevel.INFO, ROUTE_NAME + " Aggregate size =
${header.CamelAggregatedSize} "
                        + "Aggregate Completed By =
${header.CamelAggregatedCompletedBy}")

.process((Exchange exchange) -> {
                ElasticLogger.logMetric("xxxxxx", "AGG_SIZE", "count",
exchange.getIn().getHeader("CamelAggregatedSize", Integer.class));
                })

I'm not sure why the first statement is able to pick the correct header and
why the very same header is missing in the next statement.
I even added the following before and after the above two statements to see
if there's a difference in the headers. I can see that in both cases the
CamelAggregatedSize is missing.

               .process((Exchange exchange) -> {
                Map<String, Object> headers = exchange.getIn().getHeaders();
            LOG.info ("========= headers after aggregation  - part 2
====================");
            for (String key: headers.keySet()) {
            LOG.info(String.format("%s : %s", key, headers.get(key)));
            }
            LOG.info
("========================================================");
                })

Regards,

Rajith Muditha Attapattu <http://rajith.2rlabs.com/>

Reply via email to