[
https://issues.apache.org/jira/browse/CAMEL-5402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14133541#comment-14133541
]
Kevin Hinners commented on CAMEL-5402:
--------------------------------------
I would like this feature as well. Here is my service interface:
{code:title=Interface|borderStyle=solid}
public interface Transmitter {
@InOnly
public void send(@Header("uuid") String uuid, @Body String message);
}
{code}
And my Spring XML context:
{code:title=Context|borderStyle=solid}
<camelContext id="transmitContext"
xmlns="http://camel.apache.org/schema/spring">
<proxy id="transmitterProxy" serviceUrl="direct:transmitter"
serviceInterface="com.example.Transmitter"/>
<route id="transmitRoute">
<from uri="direct:transmitter"/>
<to id="auditQueue" uri="jms:queue:transmitQueue"/>
</route>
</camelContext>
{code}
However, this fails with exception:
{code:title=Exception|borderStyle=solid}
org.apache.camel.RuntimeCamelException:
org.apache.camel.InvalidPayloadException: No body available of type:
java.lang.String but has value: BeanInvocation public abstract void
com.example.Transmitter.send(java.lang.String,java.lang.String) with
[09f9a567-6f67-4600-9771-e321fa0a17d0, Hello, World!]] of type:
org.apache.camel.component.bean.BeanInvocation on: Message: BeanInvocation
public abstract void
com.example.Transmitter.send(java.lang.String,java.lang.String) with
[09f9a567-6f67-4600-9771-e321fa0a17d0, Hello, World!]]. Caused by: No type
converter available to convert from type:
org.apache.camel.component.bean.BeanInvocation to the required type:
java.lang.String with value BeanInvocation public abstract void
com.example.Transmitter.send(java.lang.String,java.lang.String) with
[09f9a567-6f67-4600-9771-e321fa0a17d0, Hello, World!]]. Exchange[Message:
BeanInvocation public abstract void
com.example.Transmitter.send(java.lang.String,java.lang.String) with
[09f9a567-6f67-4600-9771-e321fa0a17d0, Hello, World!]]]. Caused by:
[org.apache.camel.NoTypeConversionAvailableException - No type converter
available to convert from type: org.apache.camel.component.bean.BeanInvocation
to the required type: java.lang.String with value BeanInvocation public
abstract void com.example.Transmitter.send(java.lang.String,java.lang.String)
with [09f9a567-6f67-4600-9771-e321fa0a17d0, Hello, World!]]]
{code}
Underlying cause is
{code:title=Cause|borderStyle=solid}
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
converter available to convert from type:
org.apache.camel.component.bean.BeanInvocation to the required type:
java.lang.String with value BeanInvocation public abstract void
com.example.Transmitter.send(java.lang.String,java.lang.String) with
[09f9a567-6f67-4600-9771-e321fa0a17d0, Hello, World!]]
at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:181)
at
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:99)
... 65 more
{code}
Seems to me this could be accomplished since all parameters are marked as to
their purpose.
> Parameter Binding Annotations used for Camel Proxy
> --------------------------------------------------
>
> Key: CAMEL-5402
> URL: https://issues.apache.org/jira/browse/CAMEL-5402
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Affects Versions: 2.9.2
> Reporter: Anton Koscejev
> Priority: Minor
> Labels: annotations, bean, binding, parameters, proxy
>
> Parameter Binding Annotations (e.g., @Property, @Header, @Body) could be used
> to annotate an interface being proxied by Camel Proxy.
> http://camel.apache.org/parameter-binding-annotations.html used for
> http://camel.apache.org/using-camelproxy.html
> Currently these are used to identify which parameters Camel should provide
> when invoking a method of a bean. With the proposed functionality they could
> also be used to identify which parameter in the bean invocation map to body,
> and which parameters should be used to modify properties/headers. Possibly
> bypassing the creation of BeanInvocation object altogether, if @Body is
> specified.
> Example:
> public interface MyListener {
> void sendBodyWithHeader(@Body String body,
> @Header("foo") String headerFoo);
> }
> And when a Camel Proxy is created, invoking it will result in exchange having
> the String body as the OUT message with the header "foo" set to String
> headerFoo.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)