You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by user09772 <so...@gmail.com> on 2009/12/23 01:16:48 UTC

ActiveMQ - Camel as client POST?

Hey,

A oracle table is enqueuing ids to an activemq.  i Have a service as the
consumer of the queue, which dequeues ids from the queue and does a database
lookup based on that id, and eventually gets a POJO (from hibernate).  I
need a way to send this pojo to another service.  Can Camel do this for me? 
I've not used camel before.  If not, what is the best way to send a post to
another service in this scenario. 

Thanks.
-- 
View this message in context: http://old.nabble.com/ActiveMQ---Camel-as-client-POST--tp26896366p26896366.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: ActiveMQ - Camel as client POST?

Posted by Stephen Gargan <st...@gmail.com>.
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 <cl...@gmail.com> wrote:
> On Thu, Jan 7, 2010 at 10:50 PM, user09772 <so...@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 <so...@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
>

Re: How could using the split pattern avoid memory overload?

Posted by ext2 <xu...@tongtech.com>.
Oh, I am stupid;
The camel's document said clearly, the bean return iterator, and using
stream model could resolve my problem;
-----------------------------------------------------------------------
Does the split-pattern support the bean-express to return a Enumeration
instead of List?

----------------------------------------------------------------------------
Hi
	I always to do  work , it seems "the split pattern" could resolve,
but will encounter memory overload problem. To illustrate the problem, lets'
take  a example: 
	Often , we need to query records from a database , but the records
matched the condition are too much , and cannot load them to memory at all. 

	Although , using camel's splitter pattern , I could write a bean to
read database ,and  the splitter pattern ask for the bean must read all the
record and return them in a list. But this will cause critical problem.
	So is there any other means  to resolve this problem in camel? 

Thanks for any suggestion







Re: How could using the split pattern avoid memory overload?

Posted by ext2 <xu...@tongtech.com>.
Does the split-pattern support the bean-express to return a Enumeration
instead of List?

----------------------------------------------------------------------------
Hi
	I always to do  work , it seems "the split pattern" could resolve,
but will encounter memory overload problem. To illustrate the problem, lets'
take  a example: 
	Often , we need to query records from a database , but the records
matched the condition are too much , and cannot load them to memory at all. 

	Although , using camel's splitter pattern , I could write a bean to
read database ,and  the splitter pattern ask for the bean must read all the
record and return them in a list. But this will cause critical problem.
	So is there any other means  to resolve this problem in camel? 

Thanks for any suggestion





How could using the split pattern avoid memory overload?

Posted by ext2 <xu...@tongtech.com>.
Hi
	I always to do  work , it seems "the split pattern" could resolve,
but will encounter memory overload problem. To illustrate the problem, lets'
take  a example: 
	Often , we need to query records from a database , but the records
matched the condition are too much , and cannot load them to memory at all. 

	Although , using camel's splitter pattern , I could write a bean to
read database ,and  the splitter pattern ask for the bean must read all the
record and return them in a list. But this will cause critical problem.
	So is there any other means  to resolve this problem in camel? 

Thanks for any suggestion



Re: ActiveMQ - Camel as client POST?

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jan 7, 2010 at 10:50 PM, user09772 <so...@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 <so...@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

Re: ActiveMQ - Camel as client POST?

Posted by Stephen Gargan <st...@gmail.com>.
Welcome ;)

On Thu, Jan 7, 2010 at 1:50 PM, user09772 <so...@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.
>
> 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 <so...@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.
>
>

Re: ActiveMQ - Camel as client POST?

Posted by user09772 <so...@gmail.com>.
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.

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 <so...@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.


Re: ActiveMQ - Camel as client POST?

Posted by Stephen Gargan <st...@gmail.com>.
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 <so...@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.
>
>

Re: ActiveMQ - Camel as client POST?

Posted by user09772 <so...@gmail.com>.
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.


Re: ActiveMQ - Camel as client POST?

Posted by Stephen Gargan <st...@gmail.com>.
No the JsonDataFormat does not set the content type you'll need to do
that yourself. Try specifying the content type explicitly

from("direct:simple-http-send").marshal().json().setHeader(Exchange.CONTENT_TYPE,
constant("application/json")).to("http://host:port/service")

use what ever mime type your service is expecting.

There is more info here....

http://camel.apache.org/http.html

Give this a shot.

ste


On Wed, Jan 6, 2010 at 4:09 PM, user09772 <so...@gmail.com> wrote:
>
> I had the xstream depend. missing.
>
> Although I'm unable to POST to a simple Jersey service.
>
> Doing this in the camel config:
> from("direct:simple-http-send").marshal().json().to("http://host:port/service");
>
> In the consumer:
> ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
> producerTemplate.sendBody("direct:simple-http-send", sendObj);
>
>
> Getting the following exception now:
>
> Caused by: org.apache.camel.component.http.HttpOperationFailedException:
> HTTP operation failed invoking http://host:port/service with statusCode: 415
>        at
> org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:150)
>        at
> org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:92)
>        at
> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:97)
>        at
> org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:95)
>        at
> org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)
>        at
> org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:94)
>        at
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:82)
>        at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at
> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
>        at
> org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
>        at
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:93)
>        at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at
> org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:223)
>        at
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:153)
>        at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:91)
>        at
> org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
>        at
> org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:206)
>        at org.apache.camel.processor.Pipeline.process(Pipeline.java:74)
>        at
> org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:54)
>        at
> org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
>        at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
>        at
> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:45)
>        at
> org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:179)
>        at
> org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:161)
>        at
> org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)
>        at
> org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:160)
>        at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:98)
>        at
> org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:97)
>        at
> org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:110)
>        ... 27 more
>
>
>
>
>
>
> This would happen if i didn't indicate a content-type, but I'm assuming
> marshal().json()  would do this for me.  Any Ideas?
>
> Thanks.
> --
> View this message in context: http://old.nabble.com/ActiveMQ---Camel-as-client-POST--tp26896366p27026992.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Re: ActiveMQ - Camel as client POST?

Posted by user09772 <so...@gmail.com>.
I had the xstream depend. missing.

Although I'm unable to POST to a simple Jersey service.  

Doing this in the camel config:
from("direct:simple-http-send").marshal().json().to("http://host:port/service");

In the consumer:
ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
producerTemplate.sendBody("direct:simple-http-send", sendObj);


Getting the following exception now:

Caused by: org.apache.camel.component.http.HttpOperationFailedException:
HTTP operation failed invoking http://host:port/service with statusCode: 415
        at
org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:150)
        at
org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:92)
        at
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:97)
        at
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:95)
        at
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)
        at
org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:94)
        at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:82)
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
        at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)
        at
org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)
        at
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:93)
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
        at
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:223)
        at
org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:153)
        at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:91)
        at
org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)
        at
org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:206)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:74)
        at
org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:54)
        at
org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)
        at
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:45)
        at
org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:179)
        at
org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:161)
        at
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)
        at
org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:160)
        at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:98)
        at
org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:97)
        at
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:110)
        ... 27 more






This would happen if i didn't indicate a content-type, but I'm assuming
marshal().json()  would do this for me.  Any Ideas?

Thanks.
-- 
View this message in context: http://old.nabble.com/ActiveMQ---Camel-as-client-POST--tp26896366p27026992.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: ActiveMQ - Camel as client POST?

Posted by user09772 <so...@gmail.com>.
Thanks.

I've setup a route as you suggested.  I'm getting the following indicating i
need to specify dateFormat, but not sure where/how I do that.


Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
route route1 at: >>> Marshal[org.apache.camel.model.dataformat.JsonDataForm
at@1271ba] <<< in route: Route[[From[direct://simple-http-send]] ->
[Marshal[org.apac... because of dataFormat must be specified
        at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:643)
        at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:136)
        at
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:601)
        at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1156)
        at
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1073)
        at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1009)
        at
org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:158)
        at
org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:55)
        at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:884)
        at
org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:197)
        at
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101)
        ... 49 more
Caused by: java.lang.IllegalArgumentException: dataFormat must be specified
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
route route1 at: >>> Marshal[org.apache.camel.model.dataformat.JsonDataForm
at@1271ba] <<< in route: Route[[From[direct://simple-http-send]] ->
[Marshal[org.apac... because of dataFormat must be specified
        at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:643)
        at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:136)
        at
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:601)
        at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1156)
        at
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1073)
        at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1009)
        at
org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:158)
        at
org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:55)
        at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:884)
        at
org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:197)
        at
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101)
        ... 49 more
Caused by: java.lang.IllegalArgumentException: dataFormat must be specified



Stephen Gargan wrote:
> 
> Rest assured you're in the right place, Camel is exactly what you need! By
> POST i'm going to assume your service is a HTTP server of some kind?
> 
> By way of a simple example if the service is a simple http server
> expecting
> json, it might be as easy as defining a route as follows
> 
> public class SimpleJsonHttpRoute extends RouteBuilder
> {
>    public void configure() throws Exception
>    {
>        from("direct:simple-http-send").marshal().json().to("
> http://myserver:8080/service");
>    }
> }
> 
> You would use a producer template to send the hibernate pojo to the simple
> service endpoint
> 
> ProducerTemplate template = camelContext.createProducerTemplate();
> MyPojo entity = dao.loadPojo(id);
> template.sendBody("direct:simple-http-send", entity);
> 
> This would cause camel to convert the entity to a JSON string using
> XStream
> and use this as the content for a http request to the service at
> http://myserver:8080/service.
> 
> I've left out a few details here, but as Claus mentions (below), there are
> tons of examples and documentation to help you pick exactly what you need.
> If you have any questions then ping the list and someone will be happy to
> help.
> 
> rgds,
> 
> ste
> 
> from an earlier mail by Claus...
> Of course there is the camel documentation at
> http://camel.apache.org/
> 
> And the tutorials
> http://camel.apache.org/tutorials.html
> 
> And examples
> http://camel.apache.org/examples.html
> 
> And some blogs, articles on other sites at
> http://camel.apache.org/articles.html
> 
> And this thesis on Camel, although a bit old
> http://elib.uni-stuttgart.de/opus/volltexte/2008/3520/pdf/STUD_2127.pdf
> 
> And then there is a book in the works (I am one of the authors)
> http://www.manning.com/ibsen
> 
> And FUSE also have some additional documentation
> http://fusesource.com/products/enterprise-camel/#documentation
> 
> On Tue, Dec 22, 2009 at 4:16 PM, user09772 <so...@gmail.com> wrote:
>>
>> Hey,
>>
>> A oracle table is enqueuing ids to an activemq.  i Have a service as the
>> consumer of the queue, which dequeues ids from the queue and does a
> database
>> lookup based on that id, and eventually gets a POJO (from hibernate).  I
>> need a way to send this pojo to another service.  Can Camel do this for
> me?
>> I've not used camel before.  If not, what is the best way to send a post
> to
>> another service in this scenario.
>>
>> Thanks.
>> --
>> View this message in context:
> http://old.nabble.com/ActiveMQ---Camel-as-client-POST--tp26896366p26896366.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--tp26896366p27026923.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: ActiveMQ - Camel as client POST?

Posted by Stephen Gargan <st...@gmail.com>.
Rest assured you're in the right place, Camel is exactly what you need! By
POST i'm going to assume your service is a HTTP server of some kind?

By way of a simple example if the service is a simple http server expecting
json, it might be as easy as defining a route as follows

public class SimpleJsonHttpRoute extends RouteBuilder
{
   public void configure() throws Exception
   {
       from("direct:simple-http-send").marshal().json().to("
http://myserver:8080/service");
   }
}

You would use a producer template to send the hibernate pojo to the simple
service endpoint

ProducerTemplate template = camelContext.createProducerTemplate();
MyPojo entity = dao.loadPojo(id);
template.sendBody("direct:simple-http-send", entity);

This would cause camel to convert the entity to a JSON string using XStream
and use this as the content for a http request to the service at
http://myserver:8080/service.

I've left out a few details here, but as Claus mentions (below), there are
tons of examples and documentation to help you pick exactly what you need.
If you have any questions then ping the list and someone will be happy to
help.

rgds,

ste

from an earlier mail by Claus...
Of course there is the camel documentation at
http://camel.apache.org/

And the tutorials
http://camel.apache.org/tutorials.html

And examples
http://camel.apache.org/examples.html

And some blogs, articles on other sites at
http://camel.apache.org/articles.html

And this thesis on Camel, although a bit old
http://elib.uni-stuttgart.de/opus/volltexte/2008/3520/pdf/STUD_2127.pdf

And then there is a book in the works (I am one of the authors)
http://www.manning.com/ibsen

And FUSE also have some additional documentation
http://fusesource.com/products/enterprise-camel/#documentation

On Tue, Dec 22, 2009 at 4:16 PM, user09772 <so...@gmail.com> wrote:
>
> Hey,
>
> A oracle table is enqueuing ids to an activemq.  i Have a service as the
> consumer of the queue, which dequeues ids from the queue and does a
database
> lookup based on that id, and eventually gets a POJO (from hibernate).  I
> need a way to send this pojo to another service.  Can Camel do this for
me?
> I've not used camel before.  If not, what is the best way to send a post
to
> another service in this scenario.
>
> Thanks.
> --
> View this message in context:
http://old.nabble.com/ActiveMQ---Camel-as-client-POST--tp26896366p26896366.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>