問題陳述:IBM MQ主題查找返回默認的目標始終
我們對開發隊列管理器2個主題設置(USTCMN01)
一個我們開發者使用(EDM.BIRS.RDP.ONEPPM.TO_RDA )和另一個用於SIT(EDM.BIRS.RDP.S1.ONEPPM.TO_RDA)
當發佈到我們的SIT主題時,我們的消費者隊列(EDM.BIRS.RDP.S1.RDA.FROM_ONEPPM)沒有得到在另一端的消息。 我們在製作訊息時沒有收到任何異常。
問題:
當我們嘗試查找在我們的Java客戶端SIT話題,它是越來越解析爲DEV的話題,儘管事實是,我們正在提供一個其專用於SIT目的地。
IBM的MQ基礎設施由不同的團隊在附件中處理
Java客戶端代碼
例行produceWorkflowMessage()負責發佈消息
package com.cs.srp.rdp.omb;
import org.apache.bcel.classfile.ConstantClass;
import javax.jms.*;
import javax.naming.InitialContext;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyStore;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Properties;
import static javax.naming.Context.*;
public class OMBTopicPublisher {
private InitialContext ic = null;
private Connection connection;
private Session session;
ConnectionFactory connectionFactory;
private Connection createConnection() throws JMSException {
String providerCredentials = "aGMk643R";
String providerUrl = "ldap://esd-qa.csfb.net/ou=MQ,ou=Services,dc=csfb,dc=CS-Group,dc=com";
String keyStoreFile = "C:\\Balaji\\workspace\\workflowrda\\src\\main\\properties\\jks\\test\\keystore.jks";
String password = "rFzv0UOS";
String queueManagerConnectionFactory = "cn=USTCMN01_CF";
try {
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(new FileInputStream(keyStoreFile), password.toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(keyStore, password.toCharArray());
TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
tmf.init(keyStore);
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
SSLContext.setDefault(sslContext);
Hashtable<String, String> hashTable = new Hashtable<>();
hashTable.put(PROVIDER_URL, providerUrl);
hashTable.put(INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
hashTable.put(SECURITY_AUTHENTICATION, "simple");
hashTable.put(SECURITY_PRINCIPAL, "uid=MQRDP,ou=People,o=Administrators,dc=CS-Group,dc=com");
hashTable.put(SECURITY_CREDENTIALS, providerCredentials);
ic = new InitialContext(hashTable);
connectionFactory = (ConnectionFactory) ic.lookup(queueManagerConnectionFactory);
connection = connectionFactory.createConnection();
} catch (Exception e) {
System.out.println(e.getMessage());
System.out.println("Exception while trying to connect to DEV OMB queue");
}
return connection;
}
private Session createSession() throws JMSException {
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
return session;
}
private void init() throws JMSException {
createConnection();
createSession();
}
public void produceWorkflowMessage(String inboundControlMessageXML) throws JMSException {
init();
String destinationStr = "EDM.BIRS.RDP.S1.ONEPPM.TO_RDA";
MessageProducer producer;
Destination destination;
try {
destination = (Destination) ic.lookup("cn=" + destinationStr);
TextMessage message = session.createTextMessage(inboundControlMessageXML);
producer = session.createProducer(destination);
producer.send(message);
} catch (Exception e) {
System.out.println(e.getMessage());
System.out.println("Exception occured while posting message to OMB topic");
System.exit(1);
} finally {
session.close();
connection.close();
}
}
public static List<String> loadFromPropertiesFile(String propFileName) {
InputStream inputStream = null;
List<String> workflowMessageList = null;
try {
Properties workflowProperties = new Properties();
inputStream = ConstantClass.class.getClassLoader().getResourceAsStream(propFileName);
if (inputStream != null) {
workflowProperties.load(inputStream);
} else {
throw new FileNotFoundException("property file '"
+ propFileName + "' not found in the classpath");
}
workflowMessageList = new ArrayList<String>();
for (String key : workflowProperties.stringPropertyNames()) {
System.out.println("Key =" + key);
String value = workflowProperties.getProperty(key);
workflowMessageList.add(value);
}
} catch (Exception e) {
System.out.println("Error loading inboundxml worflow messages from properties file: " + e);
} finally {
try {
inputStream.close();
} catch (IOException ioe) {
System.out
.println("Exception while closing the file stream");
}
}
return workflowMessageList;
}
}
通常情況下,當有人複製Dev管理對象的詳細信息以定義SIT管理對象時,會發生這種情況。不幸的是,還沒有提供指定代碼指向的對象 - 管理對象定義 - 的一個細節。請用該信息更新問題。 –
@ T.Rob我不明白你的意思是管理對象。正如我前面所述,我們不能控制IBM MQ消息傳遞配置,並由單獨的團隊處理。我們所擁有的是共享的連接細節 – Balaji
代碼使用Java命名和目錄接口(JNDI)獲取連接和目標。使用JNDI API檢索的對象是管理對象。在消息傳遞的情況下,它們是映射Java規範的手段,該規範通常可以是專有的傳輸供應商規範。他們將專有細節封裝並抽象出來,以便應用程序不需要知道(很多)有關底層JMS傳輸的信息。這聽起來像你有兩個管理對象指向同一個MQ隊列。 @Calanais在他的回答中提供了診斷。 –