【发布时间】:2016-05-12 16:48:08
【问题描述】:
问题陈述:
我们在开发队列管理器 (USTCMN01) 上设置了 2 个主题
一个用于我们的开发用途 (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 消息传递配置,它由单独的团队处理。我们所拥有的只是共享的连接详细信息
-
代码正在使用 Java 命名和目录接口 (JNDI) 获取连接和目标。使用 JNDI API 检索的对象是托管对象。在消息传递的上下文中,它们是将通用的 Java 规范映射到可能是专有的传输供应商规范的方法。它们封装并抽象出专有细节,因此应用程序不需要(太多)了解底层 JMS 传输。听起来您有两个托管对象指向同一个 MQ 队列。 @Calanais 在他的回答中为此提供了诊断。