Q:

Camel Routing from AMQP to RESTful endpoint

I'm new to Camel and so far have been having fun with it.  However I've now come across a problem trying to read a message from AMQP and use parameters from the message to call a REST endpoint.
The idea is that the AMQP message contains a POJO which I'm reading to obtain the postcode and house number values.  These values are then being used to populate dynamic fields within the URL.
I'm using HTTP4 to perform the call to the REST endpoint and each time I hit that line I receive:
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
[route1            ] [route1            ] [spring-amqp://myExchange:getAddress:camel.getAddress?autodelete=false&durable=] [        46]
[route1            ] [log1              ] [log                                                                           ] [        13]
[route1            ] [setHeader1        ] [setHeader[CamelHttpUrl]                                                       ] [         0]
[route1            ] [setExchangePattern] [setExchangePattern[InOut]                                                     ] [         0]
[route1            ] [setHeader2        ] [setHeader[postcode]                                                           ] [        18]
[route1            ] [setHeader3        ] [setHeader[houseNumber]                                                        ] [         1]
[route1            ] [log2              ] [log                                                                           ] [         0]
[route1            ] [recipientList1    ] [recipientList[simple{Simple: https4:{{addressmicroservice.address.url}}/${head] [        13]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: Address [houseNumber=null, postcode=DY10 4TW, line1=null, line2=null, line3=null, line4=null, locality=null, town=null, county=null] of type: uk.gov.insolvency.microservices.pojos.Address on: Message[ID-Andrews-MacBook-Pro-local-56293-1472721966485-0-3]. Caused by: No type converter available to convert from type: uk.gov.insolvency.microservices.pojos.Address to the required type: java.io.InputStream with value Address [houseNumber=null, postcode=DY10 4TW, line1=null, line2=null, line3=null, line4=null, locality=null, town=null, county=null]. Exchange[ID-Andrews-MacBook-Pro-local-56293-1472721966485-0-4]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: uk.gov.insolvency.microservices.pojos.Address to the required type: java.io.InputStream with value Address [houseNumber=null, postcode=DY10 4TW, line1=null, line2=null, line3=null, line4=null, locality=null, town=null, county=null]]
at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:107)
at org.apache.camel.component.http4.HttpProducer.createRequestEntity(HttpProducer.java:523)
at org.apache.camel.component.http4.HttpProducer.createMethod(HttpProducer.java:422)
at org.apache.camel.component.http4.HttpProducer.process(HttpProducer.java:110)
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:681)
at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:609)
at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:238)
at org.apache.camel.processor.RecipientList.sendToRecipientList(RecipientList.java:170)
at org.apache.camel.processor.RecipientList.process(RecipientList.java:131)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)
at amqp.spring.camel.component.SpringAMQPConsumer$RabbitMQMessageListener.onMessage(SpringAMQPConsumer.java:201)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:757)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:680)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$001(SimpleMessageListenerContainer.java:93)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$1.invokeListener(SimpleMessageListenerContainer.java:183)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.retry.interceptor.StatefulRetryOperationsInterceptor$MethodInvocationRetryCallback.doWithRetry(StatefulRetryOperationsInterceptor.java:162)
at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:276)
at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:201)
at org.springframework.retry.interceptor.StatefulRetryOperationsInterceptor.invoke(StatefulRetryOperationsInterceptor.java:137)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
at com.sun.proxy.$Proxy50.invokeListener(Unknown Source)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.invokeListener(SimpleMessageListenerContainer.java:1358)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:661)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doReceiveAndExecute(SimpleMessageListenerContainer.java:1102)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.receiveAndExecute(SimpleMessageListenerContainer.java:1086)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$1100(SimpleMessageListenerContainer.java:93)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1203)
at amqp.spring.camel.component.SpringAMQPConsumer$SpringAMQPExecutorTask.run(SpringAMQPConsumer.java:316)
at amqp.spring.camel.component.SpringAMQPConsumer$SpringAMQPExecutorTask.run(SpringAMQPConsumer.java:316)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: uk.gov.insolvency.microservices.pojos.Address to the required type: java.io.InputStream with value Address [houseNumber=null, postcode=DY10 4TW, line1=null, line2=null, line3=null, line4=null, locality=null, town=null, county=null]
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:198)
at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:105)
... 49 common frames omitted

The Route that I'm attempting to create is:
from("spring-amqp:myExchange:getAddress:camel.getAddress?type=topic&durable=true&autodelete=false")
    .log("${body}")
    .setHeader(Exchange.HTTP_URL,
              constant("https://api.getAddress.io"))
    .setExchangePattern(ExchangePattern.InOut)
    .setHeader("postcode",
              simple("${body.postcode}"))
    .setHeader("houseNumber",
              simple("${body.houseNumber}"))
    .log("${headers}")
    .recipientList(simple("https4:{{addressmicroservice.address.url}}/${header.postcode}/${header.houseNumber}?{{addressmicroservice.address.key}}={{addressmicroservice.address.password}}&throwExceptionOnFailure=false&bridgeEndpoint=true"))
    .process(processor)
    .log("${body}");

Using Camel 2.17.2 and Java 8.

A:

From you error log, you need convert the message when exchange between the endpoints, you can refer to this Type Converter, or you can marshal/unmarshal the message to xml/json for alternative.
With camel, you can eaiser add the marshal json functionality just by call the marshal() like
from("activemq:My.Queue").
  marshal().json().
  to("mqseries:Another.Queue");

