camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "kraythe ." <kray...@gmail.com>
Subject Re: Unique instance per route but shared on the route.
Date Tue, 24 Dec 2013 08:20:42 GMT
We are seeing a transient exception while deserializing date objects. The
exception doesn't present itself if the tracer is on. The messages that hit
the DLC are able to be pushed back through with no issue. I know the mapper
is supposed to be thread safe but I'm not entirely sure it is. The problem
we have is indicative of a race condition.

On Tuesday, December 24, 2013, Richard Kettelerij wrote:

> 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 . <kraythe@gmail.com<javascript:;>>
> 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>*
> >
>


-- 
*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>*

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message