What's your concern with Jackson ObjectMappers? These actually are thread-safe, see http://wiki.fasterxml.com/JacksonFAQThreadSafety.
On Mon, Dec 23, 2013 at 11:12 PM, kraythe . <kray...@gmail.com> wrote: > Here is a tricky question. > > I have a route that is defined with concurrent consumers. Currently it > creates a single instance of a data format and then uses it in the route > several times: > > public void configureARoute() { > final ObjectMapper mapper = mapperBuilderMethod(); > final JacksonDataFormat recfmt = new JacksonDataFormat(mapper, > Record.class); > from("activemq:queue:src?concurrentConsumers=3) > .unmarshal(recfmt) > // [do things here] > .marshal(recfmt) > .to("activemq:queue:dest); > } > > The problem is I am not so sure the object mapper is totally thread safe so > I would like to create an instance of the mapper per concurrent consumer > but NOT per marshal / unmarshal call (because the actual object is used a > lot and I would have 5 of them per consumer). So what I am looking for is a > way to build an object per route concurrent consumer and use that object > throughout the route. Any ideas? > > Thanks in advance. > > *Robert Simmons Jr. MSc. - Lead Java Architect @ EA* > *Author of: Hardcore Java (2003) and Maintainable Java (2012)* > *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39 > <http://www.linkedin.com/pub/robert-simmons/40/852/a39>* >