Question

I am creating a camel route, the first steps are ok but i have trouble calling the method of another osgi bundle i made. My service expect a Long value in parameter and my pojo had only this id.

My Service :

public interface FooService {
    void bar(Long id);
}

My route :

<route>
    <from uri="direct:anEntry"/>
    <bean ref="myBean" method="bar"/>
</route>

And my data format for the route :

public class MyDto implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long myId;

    public Long getMyId() {
        return myId;
    }

    public void setMyId(Long myId) {
        this.myId= myId;
    }

    @Override
    public String toString() {
        return "MyDto [myId=" + myId+ "]";
    }

}

With this code y got a NoTypeConversionAvailableException

No type converter available to convert from type: my.company.MyDto to the required type: java.lang.Long with value MyDto [myId=141564]

I can't fin the place to convert the Dto.

I tried to make my Service expect a dto with the same structure that the one of the route but I have the same mistake.

Any Idea?

Was it helpful?

Solution

As Christian says, or call the getMyId method on the body

<bean ref="myBean" method="bar(${body.myId})"/>

See more details at

OTHER TIPS

You can add a step in the route where you convert from MyDto to Long. For example with a simple bean with this one method: Long getId(MyDto dto);

Or you can simply put a long into the route body when you call it.

If you want to share the MyDto between service and route make sure you have it in a separate bundle together with the service interface to avoid classloading problems. Do not embed the shared classes / interfaces.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top