I need to check if a message has an attachment.

In Camel2 I used the following expression:

<simple>${exchange.getIn().hasAttachments}</simple>

As attachment was modularized in Camel 3, the hasAttachments method isn't
directly available on the exchange anymore (it now extends Message).

Based on the documentation:

https://camel.apache.org/components/3.20.x/others/attachments.html

I tried:

<simple>${exchange.getIn(AttachmentMessage.class).hasAttachments}</simple>

Using Java code directly this works, but from the XML DSL this gives:

org.apache.camel.component.bean.ParameterBindingException: Error during
parameter binding on method: public abstract java.lang.Object
org.apache.camel.Exchange.getIn(java.lang.Class) at parameter #0 with type:
class java.lang.Class with value type: class java.lang.String and value:
AttachmentMessage.class

The parameter is seen as a String object, instead of AttachmentMessage
object. How to properly pass the type parameter in the XML DSL with a
simple expression? If there is an alternative way to check attachments this
also fine, but I'm trying to avoid using processors or bean invocation
though.

Raymond

Reply via email to