0

I have to unmarshall xml and send the object to cxf component. Intially I have been doing this using 'vm' queue and it was working fine. Now I want to replace it with 'jms' queue, while doing this the object cannot transfer in to jms queue. I am not getting the object in to the jms queue.

//My Jaxb config

JaxbDataFormat jaxbAuthUnmarshal = new JaxbDataFormat(jc);
    jaxbAuthUnmarshal.setContextPath(MyModel.class.getName());
    jaxbAuthUnmarshal.setPartClass(MyModel.class.getName());


//My Route
from("jms:queue:Que01?connectionFactory=#amqConnectionFactory")
.unmarshal(jaxbAuthUnmarshal)
to("jms:queue:Oue02?connectionFactory=#amqConnectionFactory");

//Additional Log information
.to("log:beforeJaxb?showAll=true")
----------------------------------- 
        beforeJaxb| 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | Exchange[Id: ID-B526DCOK-49409-1512362528955-12-27, ExchangePattern: InOnly, Properties: {CamelBinding=org.apache.camel.component.jms.JmsBinding@2916c118, CamelCreatedTimestamp=Mon Dec 04 14:28:11 IST 2017, CamelExternalRedelivered=false, CamelMessageHistory=[DefaultMessageHistory[routeId=UNMARSHALLER, node=log91], DefaultMessageHistory[routeId=UNMARSHALLER, node=to407]], CamelToEndpoint=log://beforeJaxb?showAll=true}, Headers: {breadcrumbId=ID-B526DCOK-49409-1512362528955-12-1, CamelFileAbsolute=true, CamelFileAbsolutePath=C:\INPUT\Sample_File_04Dec_12.xml, CamelFileLastModified=1511438482208, CamelFileLength=3728, CamelFileName=Sample_File_04Dec_12.xml, CamelFileNameConsumed=Sample_File_04Dec_12.xml, CamelFileNameOnly=Sample_File_04Dec_12.xml, CamelFileParent=C:\INPUT, CamelFilePath=C:\INPUT\Sample_File_04Dec_12.xml, CamelFileRelativePath=Sample_File_04Dec_12.xml, CamelJmsDeliveryMode=2, correlationId=4c6f8c74-bc96-4769-b3d3-55096d65cc6a, correlationIdDesc=GUID, JMSCorrelationID=null, JMSCorrelationIDAsBytes=null, JMSDeliveryMode=2, JMSDestination=queue://AUTH_IB_REQUEST_SPLITTED_QUEUE, JMSExpiration=0, JMSMessageID=ID:B526DCOK-49407-1512362520050-25:6:1:1:1, JMSPriority=4, JMSRedelivered=false, JMSReplyTo=null, JMSTimestamp=1512377891097, JMSType=null, JMSXGroupID=null, JMSXUserID=null, recordDesc=GUID, recordId=d97b0e6f-f300-4e1f-939b-076621d0a282, totalRecordCount=2}, BodyType: String, Body: <<Request file, removed for confidential purpose>>, Out: null: ]
.to("log:afterJaxb?showAll=true")
-----------------------------------
        afterJaxb | 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | Exchange[Id: ID-B526DCOK-49409-1512362528955-12-27, ExchangePattern: InOnly, Properties: {CamelBinding=org.apache.camel.component.jms.JmsBinding@2916c118, CamelCreatedTimestamp=Mon Dec 04 14:28:11 IST 2017, CamelExternalRedelivered=false, CamelMessageHistory=[DefaultMessageHistory[routeId=UNMARSHALLER, node=log91], DefaultMessageHistory[routeId=UNMARSHALLER, node=to407], DefaultMessageHistory[routeId=UNMARSHALLER, node=unmarshal12], DefaultMessageHistory[routeId=UNMARSHALLER, node=to408]], CamelToEndpoint=log://afterJaxb?showAll=true}, Headers: {breadcrumbId=ID-B526DCOK-49409-1512362528955-12-1, CamelFileAbsolute=true, CamelFileAbsolutePath=C:\INPUT\Sample_File_04Dec_12.xml, CamelFileLastModified=1511438482208, CamelFileLength=3728, CamelFileName=Sample_File_04Dec_12.xml, CamelFileNameConsumed=Sample_File_04Dec_12.xml, CamelFileNameOnly=Sample_File_04Dec_12.xml, CamelFileParent=C:\INPUT, CamelFilePath=C:\INPUT\Sample_File_04Dec_12.xml, CamelFileRelativePath=Sample_File_04Dec_12.xml, CamelJmsDeliveryMode=2, correlationId=4c6f8c74-bc96-4769-b3d3-55096d65cc6a, correlationIdDesc=GUID, JMSCorrelationID=null, JMSCorrelationIDAsBytes=null, JMSDeliveryMode=2, JMSDestination=queue://AUTH_IB_REQUEST_SPLITTED_QUEUE, JMSExpiration=0, JMSMessageID=ID:B526DCOK-49407-1512362520050-25:6:1:1:1, JMSPriority=4, JMSRedelivered=false, JMSReplyTo=null, JMSTimestamp=1512377891097, JMSType=null, JMSXGroupID=null, JMSXUserID=null, recordDesc=GUID, recordId=d97b0e6f-f300-4e1f-939b-076621d0a282, totalRecordCount=2}, BodyType: com.MyModel, Body: com.MyModel@4688701f, Out: null: ]
exc.getIn().getBody(Object.class)
----------------------------------
    JmsMessage[JmsMessageID: ID:B526DCOK-49407-1512362520050-25:8:1:2:1]
Hari
  • 97
  • 1
  • 14
  • A stack trace or error log would make it much easier. – ewramner Dec 04 '17 at 07:35
  • I am not getting any exception or error. while printing the object from exchange(exchange.getIn().getBody(MyModel.class)). I am getting null – Hari Dec 04 '17 at 07:38
  • And what returns `exchange.getIn().getBody(Object.class)`? Could you add some logs and paste it to question? Eg: `.to("log:beforeJaxb?showAll=true")` before `.unmarshal()` and `.to("log:afterJaxb?showAll=true")` after `.unmarshal()` – Bedla Dec 04 '17 at 08:25
  • @Bedla, after unmarshal I am able to get the object(verified by print in log).While sending the object to JMS queue, I am getting it as null. I will paste the requested logs in question – Hari Dec 04 '17 at 09:04
  • @Bedla, added the requested logs – Hari Dec 04 '17 at 09:19
  • 2
    Read the JMS documentation about using Java objects over JMS (its also a bad design to do so). It also depends on the JMS broker you use, whether its allowed, or you need to turn on which Java classes on a white/black list etc. Its better to use text based messages over JMS so they are not deeply tied to Java / Java classes. – Claus Ibsen Dec 04 '17 at 09:30
  • +1 to @ClausIbsen comment. Prefer unmarshalling your object to XML/JSON and then send it to JMS queue. In your case, you already have the XML, just send it over and marshall the object at the destination. – Ricardo Zanini Dec 04 '17 at 12:45

0 Answers0