As a workaround, I implemented it as follows: public class MyBean {
public boolean hasAttachements(Exchange exchange) { return exchange.getIn(AttachmentMessage.class).hasAttachments(); } } And then call it from the Java DSL as: <method beanType="org.assimbly.attachement.MyBean" method="hasAttachements"/> If there are better solution, I like to hear it. Raymond On Tue, Nov 14, 2023 at 8:12 PM ski n <raymondmees...@gmail.com> wrote: > > 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 > >