0

I am using Camel's POJO producing e.g.

{

public interface MyListener {
    String sayHello(String name);
}

public class MyBean {
    @Produce(uri = "activemq:foo")
    protected MyListener producer;

    public void doSomething() {
        // lets send a message
        String response = producer.sayHello("James");
    }
}

}

The interfaces using method sayHello with string object which used as body in the camel. However, If i try to use any other Object here i get exception from camel saying no TypeConvertor found for BeanInvocation for Conversion java.io.InputStream.

I know is the object was allowed it would have been mentioned somewhere. But i want to reason why it has been done like that and if there's a way to work-around this.

f_puras
  • 2,521
  • 4
  • 33
  • 38
Subodh Gupta
  • 193
  • 1
  • 3
  • 12

2 Answers2

1

I havent really used POJO messaging as yet. Maybe, an experienced user can help you better with this.

But from what I understand, it should be able to support any kind of object not just string.

The error that you're talking of seems to arise out of a mismatch down the route. I'm guessing there is some kind of issue with the consumption.

Can you please post the exact error stacktrace and the consumer method?

Thanks!

U2one
  • 381
  • 2
  • 6
0

Struggling with the same problem right now. The only obvious workaround so far is to use @EndpointInject instead of @Produce - then you get ProducerTemplate and publish any object:

    @EndpointInject(uri = "seda:report-send")
    ProducerTemplate reportSender;

Now you can do

    Object myObject = new Object();
    reportSender.sendBody(myObject);

Or even

    Object myObject = new Object();
    Map<String, Object> headers = new HashMap<String, Object>();
    headers.put("Subject", "Mail subject");
    headers.put("contentType", "text/plain");
    reportSender.sendBodyAndHeaders(myObject, headers);
rigal
  • 36
  • 5