camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: ActiveMQ - Camel as client POST?
Date Fri, 08 Jan 2010 04:57:33 GMT
On Thu, Jan 7, 2010 at 10:50 PM, user09772 <sonnyheer@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 <sonnyheer@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

Mime
View raw message