Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ODI-1227: ActiveMQObjectMessage cannot be cast to javax.jms.BytesMessage

I'm trying to get (Oracle Data Integrator 12.1.2.0.0) out of the XML from JMS queue, powered Apache ActiveMQ 5.8, but the following error:

ODI-1227: Task LKM JMS XML to SQL (Load JMS to XML) fails on the source <Empty Value> connection JMS_ActiveMQ_INVOICE_LOCAL2_CNG.
Caused By: java.sql.SQLException: java.lang.ClassCastException: org.apache.activemq.command.ActiveMQObjectMessage cannot be cast to javax.jms.BytesMessage
at com.sunopsis.jdbc.driver.SnpsDriverStatement.executeQuery(SnpsDriverStatement.java:110) 
at com.sunopsis.jdbc.driver.SnpsDriverPreparedStatement.executeQuery(SnpsDriverPreparedStatement.java:139)
at com.sunopsis.jdbc.driver.JMSXMLStatement.loadJMS(JMSXMLStatement.java:687)
at com.sunopsis.jdbc.driver.JMSXMLStatement.execute(JMSXMLStatement.java:159)
at oracle.odi.runtime.agent.execution.sql.SQLCommand.execute(SQLCommand.java:205)...

JMS-queue is external system and I am unable to change the type of messages. Can the LKM JMS XML to SQL knowledge module to process messages org.apache.activemq.command.ActiveMQObjectMessage class, that implements the interface javax.jms.BytesMessage, if so, how to config it?

Because the message of the org.apache.activemq.command.ActiveMQTextMessage class that implements the interface javax.jms.TextMessage knowledge module LKM JMS XML to SQL is successfully handles.

How do I solve this problem.

Regards, Azamat

like image 794
azamat7r Avatar asked Aug 03 '15 03:08

azamat7r


1 Answers

I have run into same problem and solved it by adding check for which type of instance is being returned in call.

if (message instanceof ActiveMQTextMessage) {
    ActiveMQTextMessage amqMessage = (ActiveMQTextMessage) message;
    mqDelegate.execute(params, amqMessage.getText());
} else {
    BytesMessage bm = (BytesMessage) message;
    byte data[] = new byte[(int) bm.getBodyLength()];
    bm.readBytes(data);
    mqDelegate.execute(params, new String(data));
}

Let me know if there is a better solution.

like image 170
Amit Kumar Avatar answered Oct 18 '22 16:10

Amit Kumar