You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Steve Hiller <sh...@bellsouth.net> on 2018/06/08 22:07:02 UTC
Simple example of passing an object in from rest to another
microservice
Hi All,
I recently watched Claus' talk called "Developing cloud-ready Camel microservices". I am trying to do the following:
rest("/candidate")
.post("applyx")
.consumes(MediaType.APPLICATION_JSON_VALUE)
.type(Candidate.class)
.to("direct:passwordlessApply")
;
from("direct:passwordlessApply")
.setExchangePattern(ExchangePattern.InOnly)
.to("http4:{{service:candidate-service}}/api/candidate/applyx")
;
where {{service:candidate-service}} also consumes the Candidate class.
However, I am seeing the following exception:
org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed
Any help is most appreciated.
Thanks,
Steve
Re: Simple example of passing an object in from rest to another
microservice
Posted by Steve Hiller <sh...@bellsouth.net>.
Thanks, Claus!
On Friday, June 15, 2018 1:29 AM, Claus Ibsen <cl...@gmail.com> wrote:
Hi
You are setting the content-length header to null
.setHeader(Exchange.CONTENT_LENGTH, constant(null))
If you want to remove it, then there is a removeHeader which you
should use instead
On Fri, Jun 15, 2018 at 1:24 AM, Steve Hiller <sh...@bellsouth.net> wrote:
> Ok, next version, which works with 1 gotcha:
>
>
> @Component
> public class RestRoute extends RouteBuilder {
>
> @Override
> public void configure()
> throws Exception
> {
> restConfiguration()
> .component("servlet")
> .producerComponent("http4")
> .bindingMode(RestBindingMode.json);
>
> rest("/candidate")
> .post("applyx")
> .consumes(MediaType.APPLICATION_JSON_VALUE)
> .type(Candidate.class)
> .route()
> .to("myProcessor")
> .marshal().json(JsonLibrary.Jackson)
> .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
> .setHeader(Exchange.CONTENT_LENGTH, constant(null))
> .to("rest:post:to/candidate/applyx?bridgeEndpoint=true&host={{service:CANDIDATE_SERVICE}}")
> .log("FROM = ${body}")
> ;
> }
> }
>
>
> So to the gotcha: I need to add the following prop to the Spring Boot application.properties file:
>
> spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
>
> or else I get the message:
>
> com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
> at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:284)
> at com.fasterxml.jackson.databind.SerializerProvider.mappingException(SerializerProvider.java:1110)
> at com.fasterxml.jackson.databind.SerializerProvider.reportMappingProblem(SerializerProvider.java:1135)
> at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:69)
> at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:32)
> at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:292)
> at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1429)
> at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:1158)
> at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:988)
> at org.apache.camel.component.jackson.JacksonDataFormat.marshal(JacksonDataFormat.java:166)
>
> Should I be worried about this?
>
>
> On Thursday, June 14, 2018 11:56 AM, Steve Hiller <sh...@bellsouth.net> wrote:
>
>
>
> Thanks, Claus! Now the following works for posting an object to the test uri http://localhost:8082/to/candidate/applyx.
> But is this the correct way?
> @Component
> public class RestRoute extends RouteBuilder {
>
> @Override
> public void configure()
> throws Exception
> {
>
> HttpComponent http = getContext().getComponent("http4", HttpComponent.class);
> http.setAllowJavaSerializedObject(true);
>
> restConfiguration()
> .component("servlet")
> .producerComponent("http4")
> .host("localhost")
> .port(8082);
>
> Candidate c = new Candidate();
> c.setFirstName("Joe");
> c.setLastName("Blow");
>
> from("timer://foo?repeatCount=1&delay=5s")
> .process(new Processor() {
> @Override
> public void process(Exchange exchange) throws Exception {
> exchange.getIn().setBody(c);
> }})
> .marshal().json(JsonLibrary.Jackson)
> .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
> .to("rest:post:to/candidate/applyx")
> .log("body = ${body}");
> }
>
> }
>
>
>
> On Thursday, June 14, 2018 5:40 AM, Claus Ibsen <cl...@gmail.com> wrote:
>
>
>
> Hi
>
> For binding to POJO classes you need to add camel-jackson to the
> classpath, and have either JAXB or Jackson annotations on the class as
> well.
>
>
> On Wed, Jun 13, 2018 at 7:34 PM, Roman Vottner <ro...@gmx.at> wrote:
>> Can you try to define
>>
>> .bindingMode(RestBindingMode.json)
>>
>> to your restConfiguration or post() definition? According to the docs (http://camel.apache.org/rest-dsl.html) it should enable conversion to/from JSON to POJO which according your your posted logs seem to fail.
>>
>> HTH,
>> roman
>>
>>
>>> Am 13.06.2018 um 15:10 schrieb Steve Hiller <sh...@bellsouth.net>:
>>>
>>> No responses -- Am I doing this completely wrong?
>>>
>>> On Friday, June 8, 2018 6:07 PM, Steve Hiller <sh...@bellsouth.net> wrote:
>>>
>>>
>>> Hi All,
>>>
>>> I recently watched Claus' talk called "Developing cloud-ready Camel microservices". I am trying to do the following:
>>>
>>> rest("/candidate")
>>> .post("applyx")
>>> .consumes(MediaType.APPLICATION_JSON_VALUE)
>>> .type(Candidate.class)
>>> .to("direct:passwordlessApply")
>>> ;
>>>
>>>
>>> from("direct:passwordlessApply")
>>> .setExchangePattern(ExchangePattern.InOnly)
>>> .to("http4:{{service:candidate-service}}/api/candidate/applyx")
>>> ;
>>>
>>>
>>> where {{service:candidate-service}} also consumes the Candidate class.
>>>
>>> However, I am seeing the following exception:
>>>
>>> org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
>>> Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
>>> Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed
>>>
>>> Any help is most appreciated.
>>>
>>> Thanks,
>>>
>>> Steve
>>>
>>>
>>
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: Simple example of passing an object in from rest to another microservice
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
You are setting the content-length header to null
.setHeader(Exchange.CONTENT_LENGTH, constant(null))
If you want to remove it, then there is a removeHeader which you
should use instead
On Fri, Jun 15, 2018 at 1:24 AM, Steve Hiller <sh...@bellsouth.net> wrote:
> Ok, next version, which works with 1 gotcha:
>
>
> @Component
> public class RestRoute extends RouteBuilder {
>
> @Override
> public void configure()
> throws Exception
> {
> restConfiguration()
> .component("servlet")
> .producerComponent("http4")
> .bindingMode(RestBindingMode.json);
>
> rest("/candidate")
> .post("applyx")
> .consumes(MediaType.APPLICATION_JSON_VALUE)
> .type(Candidate.class)
> .route()
> .to("myProcessor")
> .marshal().json(JsonLibrary.Jackson)
> .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
> .setHeader(Exchange.CONTENT_LENGTH, constant(null))
> .to("rest:post:to/candidate/applyx?bridgeEndpoint=true&host={{service:CANDIDATE_SERVICE}}")
> .log("FROM = ${body}")
> ;
> }
> }
>
>
> So to the gotcha: I need to add the following prop to the Spring Boot application.properties file:
>
> spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
>
> or else I get the message:
>
> com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
> at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:284)
> at com.fasterxml.jackson.databind.SerializerProvider.mappingException(SerializerProvider.java:1110)
> at com.fasterxml.jackson.databind.SerializerProvider.reportMappingProblem(SerializerProvider.java:1135)
> at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:69)
> at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:32)
> at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:292)
> at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1429)
> at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:1158)
> at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:988)
> at org.apache.camel.component.jackson.JacksonDataFormat.marshal(JacksonDataFormat.java:166)
>
> Should I be worried about this?
>
>
> On Thursday, June 14, 2018 11:56 AM, Steve Hiller <sh...@bellsouth.net> wrote:
>
>
>
> Thanks, Claus! Now the following works for posting an object to the test uri http://localhost:8082/to/candidate/applyx.
> But is this the correct way?
> @Component
> public class RestRoute extends RouteBuilder {
>
> @Override
> public void configure()
> throws Exception
> {
>
> HttpComponent http = getContext().getComponent("http4", HttpComponent.class);
> http.setAllowJavaSerializedObject(true);
>
> restConfiguration()
> .component("servlet")
> .producerComponent("http4")
> .host("localhost")
> .port(8082);
>
> Candidate c = new Candidate();
> c.setFirstName("Joe");
> c.setLastName("Blow");
>
> from("timer://foo?repeatCount=1&delay=5s")
> .process(new Processor() {
> @Override
> public void process(Exchange exchange) throws Exception {
> exchange.getIn().setBody(c);
> }})
> .marshal().json(JsonLibrary.Jackson)
> .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
> .to("rest:post:to/candidate/applyx")
> .log("body = ${body}");
> }
>
> }
>
>
>
> On Thursday, June 14, 2018 5:40 AM, Claus Ibsen <cl...@gmail.com> wrote:
>
>
>
> Hi
>
> For binding to POJO classes you need to add camel-jackson to the
> classpath, and have either JAXB or Jackson annotations on the class as
> well.
>
>
> On Wed, Jun 13, 2018 at 7:34 PM, Roman Vottner <ro...@gmx.at> wrote:
>> Can you try to define
>>
>> .bindingMode(RestBindingMode.json)
>>
>> to your restConfiguration or post() definition? According to the docs (http://camel.apache.org/rest-dsl.html) it should enable conversion to/from JSON to POJO which according your your posted logs seem to fail.
>>
>> HTH,
>> roman
>>
>>
>>> Am 13.06.2018 um 15:10 schrieb Steve Hiller <sh...@bellsouth.net>:
>>>
>>> No responses -- Am I doing this completely wrong?
>>>
>>> On Friday, June 8, 2018 6:07 PM, Steve Hiller <sh...@bellsouth.net> wrote:
>>>
>>>
>>> Hi All,
>>>
>>> I recently watched Claus' talk called "Developing cloud-ready Camel microservices". I am trying to do the following:
>>>
>>> rest("/candidate")
>>> .post("applyx")
>>> .consumes(MediaType.APPLICATION_JSON_VALUE)
>>> .type(Candidate.class)
>>> .to("direct:passwordlessApply")
>>> ;
>>>
>>>
>>> from("direct:passwordlessApply")
>>> .setExchangePattern(ExchangePattern.InOnly)
>>> .to("http4:{{service:candidate-service}}/api/candidate/applyx")
>>> ;
>>>
>>>
>>> where {{service:candidate-service}} also consumes the Candidate class.
>>>
>>> However, I am seeing the following exception:
>>>
>>> org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
>>> Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
>>> Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed
>>>
>>> Any help is most appreciated.
>>>
>>> Thanks,
>>>
>>> Steve
>>>
>>>
>>
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: Simple example of passing an object in from rest to another
microservice
Posted by Steve Hiller <sh...@bellsouth.net>.
Ok, next version, which works with 1 gotcha:
@Component
public class RestRoute extends RouteBuilder {
@Override
public void configure()
throws Exception
{
restConfiguration()
.component("servlet")
.producerComponent("http4")
.bindingMode(RestBindingMode.json);
rest("/candidate")
.post("applyx")
.consumes(MediaType.APPLICATION_JSON_VALUE)
.type(Candidate.class)
.route()
.to("myProcessor")
.marshal().json(JsonLibrary.Jackson)
.setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
.setHeader(Exchange.CONTENT_LENGTH, constant(null))
.to("rest:post:to/candidate/applyx?bridgeEndpoint=true&host={{service:CANDIDATE_SERVICE}}")
.log("FROM = ${body}")
;
}
}
So to the gotcha: I need to add the following prop to the Spring Boot application.properties file:
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
or else I get the message:
com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:284)
at com.fasterxml.jackson.databind.SerializerProvider.mappingException(SerializerProvider.java:1110)
at com.fasterxml.jackson.databind.SerializerProvider.reportMappingProblem(SerializerProvider.java:1135)
at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:69)
at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:32)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:292)
at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1429)
at com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:1158)
at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:988)
at org.apache.camel.component.jackson.JacksonDataFormat.marshal(JacksonDataFormat.java:166)
Should I be worried about this?
On Thursday, June 14, 2018 11:56 AM, Steve Hiller <sh...@bellsouth.net> wrote:
Thanks, Claus! Now the following works for posting an object to the test uri http://localhost:8082/to/candidate/applyx.
But is this the correct way?
@Component
public class RestRoute extends RouteBuilder {
@Override
public void configure()
throws Exception
{
HttpComponent http = getContext().getComponent("http4", HttpComponent.class);
http.setAllowJavaSerializedObject(true);
restConfiguration()
.component("servlet")
.producerComponent("http4")
.host("localhost")
.port(8082);
Candidate c = new Candidate();
c.setFirstName("Joe");
c.setLastName("Blow");
from("timer://foo?repeatCount=1&delay=5s")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody(c);
}})
.marshal().json(JsonLibrary.Jackson)
.setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
.to("rest:post:to/candidate/applyx")
.log("body = ${body}");
}
}
On Thursday, June 14, 2018 5:40 AM, Claus Ibsen <cl...@gmail.com> wrote:
Hi
For binding to POJO classes you need to add camel-jackson to the
classpath, and have either JAXB or Jackson annotations on the class as
well.
On Wed, Jun 13, 2018 at 7:34 PM, Roman Vottner <ro...@gmx.at> wrote:
> Can you try to define
>
> .bindingMode(RestBindingMode.json)
>
> to your restConfiguration or post() definition? According to the docs (http://camel.apache.org/rest-dsl.html) it should enable conversion to/from JSON to POJO which according your your posted logs seem to fail.
>
> HTH,
> roman
>
>
>> Am 13.06.2018 um 15:10 schrieb Steve Hiller <sh...@bellsouth.net>:
>>
>> No responses -- Am I doing this completely wrong?
>>
>> On Friday, June 8, 2018 6:07 PM, Steve Hiller <sh...@bellsouth.net> wrote:
>>
>>
>> Hi All,
>>
>> I recently watched Claus' talk called "Developing cloud-ready Camel microservices". I am trying to do the following:
>>
>> rest("/candidate")
>> .post("applyx")
>> .consumes(MediaType.APPLICATION_JSON_VALUE)
>> .type(Candidate.class)
>> .to("direct:passwordlessApply")
>> ;
>>
>>
>> from("direct:passwordlessApply")
>> .setExchangePattern(ExchangePattern.InOnly)
>> .to("http4:{{service:candidate-service}}/api/candidate/applyx")
>> ;
>>
>>
>> where {{service:candidate-service}} also consumes the Candidate class.
>>
>> However, I am seeing the following exception:
>>
>> org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
>> Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
>> Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed
>>
>> Any help is most appreciated.
>>
>> Thanks,
>>
>> Steve
>>
>>
>
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: Simple example of passing an object in from rest to another
microservice
Posted by Steve Hiller <sh...@bellsouth.net>.
Thanks, Claus! Now the following works for posting an object to the test uri http://localhost:8082/to/candidate/applyx.
But is this the correct way?
@Component
public class RestRoute extends RouteBuilder {
@Override
public void configure()
throws Exception
{
HttpComponent http = getContext().getComponent("http4", HttpComponent.class);
http.setAllowJavaSerializedObject(true);
restConfiguration()
.component("servlet")
.producerComponent("http4")
.host("localhost")
.port(8082);
Candidate c = new Candidate();
c.setFirstName("Joe");
c.setLastName("Blow");
from("timer://foo?repeatCount=1&delay=5s")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody(c);
}})
.marshal().json(JsonLibrary.Jackson)
.setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
.to("rest:post:to/candidate/applyx")
.log("body = ${body}");
}
}
On Thursday, June 14, 2018 5:40 AM, Claus Ibsen <cl...@gmail.com> wrote:
Hi
For binding to POJO classes you need to add camel-jackson to the
classpath, and have either JAXB or Jackson annotations on the class as
well.
On Wed, Jun 13, 2018 at 7:34 PM, Roman Vottner <ro...@gmx.at> wrote:
> Can you try to define
>
> .bindingMode(RestBindingMode.json)
>
> to your restConfiguration or post() definition? According to the docs (http://camel.apache.org/rest-dsl.html) it should enable conversion to/from JSON to POJO which according your your posted logs seem to fail.
>
> HTH,
> roman
>
>
>> Am 13.06.2018 um 15:10 schrieb Steve Hiller <sh...@bellsouth.net>:
>>
>> No responses -- Am I doing this completely wrong?
>>
>> On Friday, June 8, 2018 6:07 PM, Steve Hiller <sh...@bellsouth.net> wrote:
>>
>>
>> Hi All,
>>
>> I recently watched Claus' talk called "Developing cloud-ready Camel microservices". I am trying to do the following:
>>
>> rest("/candidate")
>> .post("applyx")
>> .consumes(MediaType.APPLICATION_JSON_VALUE)
>> .type(Candidate.class)
>> .to("direct:passwordlessApply")
>> ;
>>
>>
>> from("direct:passwordlessApply")
>> .setExchangePattern(ExchangePattern.InOnly)
>> .to("http4:{{service:candidate-service}}/api/candidate/applyx")
>> ;
>>
>>
>> where {{service:candidate-service}} also consumes the Candidate class.
>>
>> However, I am seeing the following exception:
>>
>> org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
>> Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
>> Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed
>>
>> Any help is most appreciated.
>>
>> Thanks,
>>
>> Steve
>>
>>
>
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: Simple example of passing an object in from rest to another microservice
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
For binding to POJO classes you need to add camel-jackson to the
classpath, and have either JAXB or Jackson annotations on the class as
well.
On Wed, Jun 13, 2018 at 7:34 PM, Roman Vottner <ro...@gmx.at> wrote:
> Can you try to define
>
> .bindingMode(RestBindingMode.json)
>
> to your restConfiguration or post() definition? According to the docs (http://camel.apache.org/rest-dsl.html) it should enable conversion to/from JSON to POJO which according your your posted logs seem to fail.
>
> HTH,
> roman
>
>
>> Am 13.06.2018 um 15:10 schrieb Steve Hiller <sh...@bellsouth.net>:
>>
>> No responses -- Am I doing this completely wrong?
>>
>> On Friday, June 8, 2018 6:07 PM, Steve Hiller <sh...@bellsouth.net> wrote:
>>
>>
>> Hi All,
>>
>> I recently watched Claus' talk called "Developing cloud-ready Camel microservices". I am trying to do the following:
>>
>> rest("/candidate")
>> .post("applyx")
>> .consumes(MediaType.APPLICATION_JSON_VALUE)
>> .type(Candidate.class)
>> .to("direct:passwordlessApply")
>> ;
>>
>>
>> from("direct:passwordlessApply")
>> .setExchangePattern(ExchangePattern.InOnly)
>> .to("http4:{{service:candidate-service}}/api/candidate/applyx")
>> ;
>>
>>
>> where {{service:candidate-service}} also consumes the Candidate class.
>>
>> However, I am seeing the following exception:
>>
>> org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
>> Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
>> Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed
>>
>> Any help is most appreciated.
>>
>> Thanks,
>>
>> Steve
>>
>>
>
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: Simple example of passing an object in from rest to another
microservice
Posted by Roman Vottner <ro...@gmx.at>.
Can you try to define
.bindingMode(RestBindingMode.json)
to your restConfiguration or post() definition? According to the docs (http://camel.apache.org/rest-dsl.html) it should enable conversion to/from JSON to POJO which according your your posted logs seem to fail.
HTH,
roman
> Am 13.06.2018 um 15:10 schrieb Steve Hiller <sh...@bellsouth.net>:
>
> No responses -- Am I doing this completely wrong?
>
> On Friday, June 8, 2018 6:07 PM, Steve Hiller <sh...@bellsouth.net> wrote:
>
>
> Hi All,
>
> I recently watched Claus' talk called "Developing cloud-ready Camel microservices". I am trying to do the following:
>
> rest("/candidate")
> .post("applyx")
> .consumes(MediaType.APPLICATION_JSON_VALUE)
> .type(Candidate.class)
> .to("direct:passwordlessApply")
> ;
>
>
> from("direct:passwordlessApply")
> .setExchangePattern(ExchangePattern.InOnly)
> .to("http4:{{service:candidate-service}}/api/candidate/applyx")
> ;
>
>
> where {{service:candidate-service}} also consumes the Candidate class.
>
> However, I am seeing the following exception:
>
> org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
> Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
> Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed
>
> Any help is most appreciated.
>
> Thanks,
>
> Steve
>
>
Re: Simple example of passing an object in from rest to another
microservice
Posted by Steve Hiller <sh...@bellsouth.net>.
No responses -- Am I doing this completely wrong?
On Friday, June 8, 2018 6:07 PM, Steve Hiller <sh...@bellsouth.net> wrote:
Hi All,
I recently watched Claus' talk called "Developing cloud-ready Camel microservices". I am trying to do the following:
rest("/candidate")
.post("applyx")
.consumes(MediaType.APPLICATION_JSON_VALUE)
.type(Candidate.class)
.to("direct:passwordlessApply")
;
from("direct:passwordlessApply")
.setExchangePattern(ExchangePattern.InOnly)
.to("http4:{{service:candidate-service}}/api/candidate/applyx")
;
where {{service:candidate-service}} also consumes the Candidate class.
However, I am seeing the following exception:
org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed...
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: com.rusa.adapter.mobile.candidate.domain.Candidate to the required type: java.io.InputStream with value com.rusa.adapter.mobile.candidate.domain.Candidate@58af86ed
Any help is most appreciated.
Thanks,
Steve