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

1

6

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

Christology answered 3/8, 2015 at 3:55 Comment(1)
Are you sending message from ActiveMq UI? Can use show you code?Overleap
O
9

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.

Overleap answered 23/10, 2015 at 6:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.