Agreed,If switching between them didn't require adding the extra
dependency it might not be such a big deal. Say if there were a
camel-json that was a facade like dependency that transitively
included xstream and jackson. The pro being you could easily swap json
providers to see which met your needs best, the major con being an
unused provider dependency in your classpath. Once you'd worked out
which suited best you could just include explicitly it or exclude the
other from camel-json.

At a higher granularity there could also be camel-dataformats, that
aggregates all the dataformat components. If you don't really care
about unused dependencies then this might be an option.

One other thing that help would be If it were possible to configure
Xstream to run in Drop root mode as this might remove some of the
confusion

http://xstream.codehaus.org/json-tutorial.html

2c.

ste


On Thu, Jan 7, 2010 at 8:57 PM, Claus Ibsen <claus.ib...@gmail.com> wrote:
> On Thu, Jan 7, 2010 at 10:50 PM, user09772 <sonnyh...@gmail.com> wrote:
>>
>> Excellent!  thanks!
>>
>> I had trouble using the default XStream library, basically I don't know how
>> to set the alias for my POJO.  Using Jackson works as expected.
>>
>
> Yeah I wonder if we should switch default? But that will break
> existing routes for people using that default.
> But IMHO Jackson is better than the XStream for JSON.
>
>
>> Thanks once again.
>>
>>
>> Stephen Gargan wrote:
>>>
>>> Yes there are a number of ways. Easiest is to add a log step to your route
>>> e.g.
>>>
>>> from("direct:simple-http-send").marshal().json(JsonLibrary.Jackson).setHeader(Exchange.CONTENT_TYPE,
>>> constant("application/json")).to("log:marshalled-object").to("http://host:port/service";)
>>>
>>> This should kick out a log message similar to
>>>
>>> 2010-01-07 12:23:33,830 [main] marshalled-object         INFO
>>> Exchange[BodyType:byte[], Body:{"name":"Hello","value":"Camel"}]
>>>
>>> Alternatively, If you'd like to see the flow of an exchange through
>>> your route you could add a trace interceptor to the context. Somewhere
>>> where you have access to the Camel Context, call the following. I
>>> typically avoid adding the tracer unless the log level is debug or
>>> trace as it can be very verbose.
>>>
>>>  public void addTraceInterceptor(CamelContext context) throws Exception
>>>     {
>>>         if (log.isTraceEnabled())
>>>         {
>>>             log.trace("Adding Tracing interceptor to Camel Context.");
>>>             Tracer tracer = new Tracer();
>>>             context.addInterceptStrategy(tracer);
>>>         }
>>>     }
>>>
>>> If you want to get fancy you can define a formatter to control what
>>> the tracer outputs. Say for instance the body of your message was a
>>> document of a meg or so, you might want to turn off logging this huge
>>> amount of data (or possibly truncate it for logging). To do this add a
>>> custom formatter as follows.
>>>
>>> DefaultTraceFormatter formatter = new DefaultTraceFormatter();
>>> formatter.setShowBody(false);
>>> tracer.setFormatter(formatter);
>>>
>>> As ever, the excellent documentation on Tracers will tell you
>>> everything you need to know and more
>>>
>>> http://camel.apache.org/tracer.html
>>> http://camel.apache.org/tracer-example.html
>>>
>>> In general the Tracer is better for debugging and the log component is
>>> best for creating a paper trail in production. Both will serve your
>>> logging purposes so give em a try and see which one suits you best.
>>>
>>> rgds
>>>
>>> ste
>>>
>>>
>>> On Thu, Jan 7, 2010 at 10:43 AM, user09772 <sonnyh...@gmail.com> wrote:
>>>>
>>>> Thanks Stephen!
>>>>
>>>> That fixed the 415 error.
>>>>
>>>> Is there a way to output/view the actual marshalled json object?
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/ActiveMQ---Camel-as-client-POST--tp26896366p27064923.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context: 
>> http://old.nabble.com/ActiveMQ---Camel-as-client-POST--tp26896366p27067619.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>

Reply via email to