1

I'm trying to add a SolrInputDocment (which is Serializable) to an ActiveMQ queue (using a Camel producer template), but I get a MessageFormatException...any ideas?

here is my code...

SolrInputDocument doc1 = new SolrInputDocument();
doc1.addField( "id", "1234", 1.0f );

template.sendBody("activemq:queue:test", doc1);

here is my error...

Caused by: javax.jms.MessageFormatException: Only objectified primitive objects, String, Map and List types are allowed but was: id(1.0)={1234} type: class org.apache.solr.common.SolrInputField

UPDATE: the issue is that I need to explicitly set the JMSMessageType to 'Object', otherwise the MapMessage is used (which doesn't support custom types)...

template.sendBodyAndHeader("activemq:queue:test", doc1, JMS_MESSAGE_TYPE, "Object");
Ben ODay
  • 20,784
  • 9
  • 45
  • 68

1 Answers1

2

Seems like your message properties contain some complex java Object, how about if you try to send a "clean" SolrInputDocument?

Cheers,Eugene.

Eugene
  • 117,005
  • 15
  • 201
  • 306
  • thanks, w/o the addField() call, it does work...strange that calling addField() (which creates a LinkedHashMap all of which are Serializable) breaks it... – Ben ODay Feb 07 '12 at 16:27
  • @boday what I did is look into the sources of where this Exception is thrown, and there I saw that it has to do with message PROPERTIES and not the body, so that was my first hint to look. So Serializable I think has nothing to do with it. Anyhow if it helped I would appreciated and extra 15 on my account :) Thx! – Eugene Feb 07 '12 at 16:35
  • thanks for your input...but I'm not explicitly setting any properties...hence my confusion. this works fine w/o calling addField() (which only affects the body)...also, I tried with another POJO object and it works fine as well...anyways, its a strange error – Ben ODay Feb 07 '12 at 16:56
  • @boday weird indeed then. Is there a way you could add a Filter may be to catch this request to see how it looks like? – Eugene Feb 07 '12 at 16:59
  • Camel must be causing this...I switched to using a JMSTemplate directly it worked fine... – Ben ODay Feb 09 '12 at 00:36
  • @boday really glad you got it solved then. Seems like Camel is adding something behinds the scenes, might test it myself whenever I have a bit of free time. Cheers, Eugene. – Eugene Feb 09 '12 at 08:10
  • @boday good to know for people in the future who will try the same thing. You actually deserve a +15 yourself :) – Eugene Feb 11 '12 at 10:53