我需要連接到不同數據庫中的兩個Oracle AQ隊列。在兩種情況下,我都使用完全相似的代碼,除了連接字符串。其中一個隊列工作正常,但第二個隊列沒有。使用JMS從Oracle AQ收到的TextMessage包含'???'
String db_string = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=x.y.z.2)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=x.y.z.3)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=DBNAME)))";
String name = "scott";
String pwd = "tiger";
Properties info = new Properties();
info.put("name", name);
info.put("password", pwd);
QueueConnectionFactory q_cf = AQjmsFactory.getQueueConnectionFactory(db_string, info);
QueueConnection q_conn q_conn = q_cf.createQueueConnection(name, pwd);
QueueSession q_sess = q_conn.createQueueSession(true, Session.CLIENT_ACKNOWLEDGE);
q_conn.start();
Queue queue = ((AQjmsSession) q_sess).getQueue("test","myaq");
((AQjmsDestination) queue).start(q_sess, true, true);
QueueReceiver q_recvr = q_sess.createReceiver(queue);
TextMessage message = (TextMessage) q_recvr.receive();
System.out.println(message.getText());
當我使用代碼連接到工作正常的AQ時,它正確地打印消息中包含的文本。不管郵件內容如何,第二個AQ只打印三個引號。
我正在使用aqapi 10.2.0.2,並且已經使用ojdbc14 10.2.0.2.0和ojdbc5 11.1.0.6.0進行了測試。正在運行的AQ正在Oracle 11.1.0.0.0上運行,並且正在導致10.2.0.4.0上的問題。我用Wireshark分析了TNS數據包,包含AQ消息的數據包與這兩個數據庫看起來非常相似。工作情況的TextMessage對象的
反思轉儲看起來是這樣的:
{text_[email protected][email protected]_lob=m_boolClass=class java.lang.Booleanm_byteClass=class java.lang.Bytem_shortClass=class java.lang.Bytem_intClass=class java.lang.Integerm_longClass=class java.lang.Longm_floatClass=class java.lang.Floatm_doubleClass=class java.lang.Doublem_strClass=class java.lang.Stringm_systemProperties={JMSXDeliveryCount=class java.lang.Integer, JMS_OracleConnectionID=class java.lang.String, JMSXGroupSeq=class java.lang.Integer, JMSXAppID=class java.lang.String, JMSXRecvTimestamp=class java.lang.Long, JMS_OracleExcpQ=class java.lang.String, JMS_OracleHeaderOnly=class java.lang.String, JMS_OracleOriginalMessageID=class java.lang.String, JMSXGroupID=class java.lang.String, JMSXUserID=class java.lang.String, JMS_OracleDeliveryMode=class java.lang.String, JMS_OracleTimestamp=class java.lang.Long, JMS_OracleDelay=class java.lang.Long, JMSXState=class java.lang.Integer}m_settableSystemProperties=[JMSXGroupID, JMSXGroupSeq][email protected]_[email protected]_time=1265887454000corr_id=msg_dest=test.myaqdel_mode=2redelivered=trueexpiration=0priority=1msg_properties={[email protected]}access_mode=0prop_read_only=truerecv_time=1265891032384msg_state=0excp_queue=msg_delay=0orig_msg_id=[email protected]a613f8m_hdrOnly=falsem_isjmsbody=truecompliant=falseJMS_REPLY_TO=JMSReplyTo}
而破一個:
{[email protected][email protected]_lob=m_boolClass=class java.lang.Booleanm_byteClass=class java.lang.Bytem_shortClass=class java.lang.Bytem_intClass=class java.lang.Integerm_longClass=class java.lang.Longm_floatClass=class java.lang.Floatm_doubleClass=class java.lang.Doublem_strClass=class java.lang.Stringm_systemProperties={JMSXDeliveryCount=class java.lang.Integer, JMS_OracleConnectionID=class java.lang.String, JMSXGroupSeq=class java.lang.Integer, JMSXAppID=class java.lang.String, JMSXRecvTimestamp=class java.lang.Long, JMS_OracleExcpQ=class java.lang.String, JMS_OracleHeaderOnly=class java.lang.String, JMS_OracleOriginalMessageID=class java.lang.String, JMSXGroupID=class java.lang.String, JMSXUserID=class java.lang.String, JMS_OracleDeliveryMode=class java.lang.String, JMS_OracleTimestamp=class java.lang.Long, JMS_OracleDelay=class java.lang.Long, JMSXState=class java.lang.Integer}m_settableSystemProperties=[JMSXGroupSeq, JMSXGroupID][email protected][email protected]_time=1265890738000corr_id=msg_dest=test.myaqdel_mode=2redelivered=trueexpiration=0priority=1msg_properties={[email protected]}access_mode=0prop_read_only=truerecv_time=1265891388844msg_state=0excp_queue=msg_delay=0orig_msg_id=[email protected]60e128m_hdrOnly=falsem_isjmsbody=truecompliant=falseJMS_REPLY_TO=JMSReplyTo}