我有一个功能,我试图将消息发布到JMS主题。此功能作为休息端点公开,并部署在weblogic服务器中。但是,我面临的问题是在weblogic启动时单独使用一次。当我尝试对其余端点进行集成测试时,它会在尝试创建会话的代码片段中引发以下异常。
我已经使用IBM MQ Jars进行JMS集成以及来自Javax扩展的类。 (IBM MQ版本 - 7.0.1.9)
以下是我在尝试创建连接时抛出的代码段和异常
private Connection createConnection() {
ombConnectionProperties = loadOmbConnectionProperties();
if (ombConnectionProperties.size() == 0 || ombConnectionProperties == null) {
buildBusinessException("Could not load OMB properties from environment resource", ExceptionStatus.INTERNAL_SERVER_ERROR);
}
try {
initSSL(ombConnectionProperties);
Hashtable<String, String> initialContextPropertiesMatrix = buildInitialContextPropertiesMatrix(ombConnectionProperties);
ic = new InitialContext(initialContextPropertiesMatrix);
if(ombConnectionProperties.getProperty("workflow.omb.queueManager")!=null) {
if(ic!=null) {
connectionFactory = (ConnectionFactory) ic.lookup(ombConnectionProperties.getProperty("workflow.omb.queueManager"));
}
}
if(connectionFactory!=null) {
connection = connectionFactory.createConnection();
}
} catch (Exception e) {
propagateException(e);
}
return connection;
}
private Session createSession() {
try {
if(connection!=null) {
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
}catch (Exception e) {
propagateException(e);
}
return session;
}
private Hashtable<String, String> buildInitialContextPropertiesMatrix(Properties ombConnectionProperties) {
Hashtable<String, String> initialContextPropertiesMatrix = new Hashtable<String, String>();
if (ombConnectionProperties.getProperty("workflow.omb.ldapProviderUrl") != null) {
initialContextPropertiesMatrix.put(PROVIDER_URL, ombConnectionProperties.getProperty("workflow.omb.ldapProviderUrl"));
}
initialContextPropertiesMatrix.put(INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
initialContextPropertiesMatrix.put(SECURITY_AUTHENTICATION, "simple");
if (ombConnectionProperties.getProperty("workflow.omb.ldapPrincipal") != null) {
initialContextPropertiesMatrix.put(SECURITY_PRINCIPAL, ombConnectionProperties.getProperty("workflow.omb.ldapPrincipal"));
}
if (ombConnectionProperties.getProperty("workflow.omb.ldapCredential") != null) {
initialContextPropertiesMatrix.put(SECURITY_CREDENTIALS, ombConnectionProperties.getProperty("workflow.omb.ldapCredential"));
}
return initialContextPropertiesMatrix;
}
public void publishWorkflowControlMessage(String workflowName, String action) {
try {
init();
String inboundControlMessageXML = buildWorkflowControlMessageXML(workflowName, action);
Destination destination = null;
if (ombConnectionProperties.getProperty("workflow.omb.topicName") != null) {
destination = (Destination) ic.lookup("cn=" + ombConnectionProperties.getProperty("workflow.omb.topicName"));
}
MessageProducer producer;
producer = session.createProducer(destination);
TextMessage message = session.createTextMessage(inboundControlMessageXML);
producer.send(message);
} catch (Exception e) {
propagateException(e);
} finally {
try {
if(session!=null){
session.close();
}
if(connection!=null){
connection.close();
}
} catch (JMSException e) {
LOG.error("Exception Occured while closing the OMB connection", e);
throw new RuntimeException("Exception occured while trying to close the OMB connection", e);
}
}
}
workflow.omb.ldapProviderUrl = ldap://esdqa.csfb.net/ou=MQ,ou=Services,dc=csfb,dc=CS-Group,dc=com
workflow.omb.ldapPrincipal = uid=MQRDP,ou=People,o=Administrators,dc=CS- Group,dc=com
workflow.omb.ldapCredentials = aGMk643R
workflow.omb.queueManager = cn=USTCMN01_CF
workflow.omb.topicName = EDM.BIRS.RDP.ONEPPM.TO_RDA
workflow.omb.certificate.url = properties//jks//test//keystore.jks
workflow.omb.certificate.password = rFzv0UOS
PS:只有当我尝试在服务器启动时连接到JMS时才会出现此问题。当我第二次尝试它工作正常时,从那时起就没有问题,我可以向主题发布消息。我不知道什么是错的。但是,当我作为一个独立的客户端执行这个程序时,它工作正常。
Caused by: java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:417)
at java.lang.Short.parseShort(Short.java:120)
at java.lang.Short.valueOf(Short.java:153)
at java.lang.Short.valueOf(Short.java:178)
at com.ibm.msg.client.jms.internal.JmsReadablePropertyContextImpl.parseShort(JmsReadablePropertyContextImpl.java:752)
at com.ibm.msg.client.jms.internal.JmsReadablePropertyContextImpl.getShortProperty(JmsReadablePropertyContextImpl.java:326)
at com.ibm.msg.client.wmq.common.internal.WMQPropertyContext.getShortProperty(WMQPropertyContext.java:360)
at com.ibm.msg.client.wmq.internal.WMQSession.<init>(WMQSession.java:311)
at com.ibm.msg.client.wmq.internal.WMQConnection.createSession(WMQConnection.java:980)
at com.ibm.msg.client.jms.internal.JmsConnectionImpl.createSession(JmsConnectionImpl.java:572)
at com.ibm.mq.jms.MQConnection.createSession(MQConnection.java:339)
我在调试bug中评估的连接对象中添加了属性。当我第一次调用对象的大小为77时调用该调用时,当我再次调用该调用时,大小增加到78,这将解析它,并且它是初始连接对象中缺少的属性“XMSC_ADMIN_OBJECT_TYPE”。我正在粘贴下面的整个列表
0 = {HashMap$Entry@18264} "XMSC_WMQ_HEADER_COMP" -> " size = 1"
1 = {HashMap$Entry@18265} "wildcardFormat" -> "0"
2 = {HashMap$Entry@18266} "XMSC_WMQ_BROKER_PUBQ" -> "SYSTEM.BROKER.DEFAULT.STREAM"
3 = {HashMap$Entry@18267} "XMSC_WMQ_CONNECTION_TAG" ->
4 = {HashMap$Entry@18268} "XMSC_WMQ_BROKER_SUBQ" -> "SYSTEM.JMS.ND.SUBSCRIBER.QUEUE"
5 = {HashMap$Entry@18269} "XMSC_WMQ_SHARE_CONV_ALLOWED" -> "1"
6 = {HashMap$Entry@18270} "XMSC_WMQ_SSL_SOCKET_FACTORY" -> "null"
7 = {HashMap$Entry@18271} "multicast" -> "0"
8 = {HashMap$Entry@18272} "brokerVersion" -> "-1"
9 = {HashMap$Entry@18273} "XMSC_WMQ_MESSAGE_SELECTION" -> "0"
10 = {HashMap$Entry@18274} "XMSC_WMQ_CLEANUP_LEVEL" -> "1"
11 = {HashMap$Entry@18275} "XMSC_CLIENT_ID" -> "null"
12 = {HashMap$Entry@18276} "XMSC_WMQ_SUBSCRIPTION_STORE" -> "1"
13 = {HashMap$Entry@18277} "XMSC_WMQ_RECEIVE_EXIT" -> "null"
14 = {HashMap$Entry@18278} "XMSC_WMQ_SSL_CERT_STORES_COL" -> "null"
15 = {HashMap$Entry@18279} "XMSC_WMQ_CLIENT_RECONNECT_TIMEOUT" -> "1800"
16 = {HashMap$Entry@18280} "XMSC_WMQ_RECEIVE_EXIT_INIT" -> "null"
17 = {HashMap$Entry@18281} "XMSC_WMQ_TEMP_TOPIC_PREFIX" ->
18 = {HashMap$Entry@18282} "XMSC_WMQ_CONNECT_OPTIONS" -> "0"
19 = {HashMap$Entry@18283} "XMSC_WMQ_MAP_NAME_STYLE" -> "true"
20 = {HashMap$Entry@18284} "XMSC_WMQ_MSG_BATCH_SIZE" -> "10"
21 = {HashMap$Entry@18285} "XMSC_WMQ_USE_CONNECTION_POOLING" -> "true"
22 = {HashMap$Entry@18286} "XMSC_WMQ_TARGET_CLIENT_MATCHING" -> "true"
23 = {HashMap$Entry@18287} "XMSC_USERID" ->
24 = {HashMap$Entry@18288} "XMSC_WMQ_SPARSE_SUBSCRIPTIONS" -> "false"
25 = {HashMap$Entry@18289} "XMSC_WMQ_MSG_COMP" -> " size = 1"
26 = {HashMap$Entry@18290} "XMSC_WMQ_MAX_BUFFER_SIZE" -> "1000"
27 = {HashMap$Entry@18291} "XMSC_WMQ_CONNECTION_MODE" -> "1"
28 = {HashMap$Entry@18292} "XMSC_WMQ_CLIENT_RECONNECT_OPTIONS" -> "0"
29 = {HashMap$Entry@18293} "XMSC_WMQ_CHANNEL" -> "USTCMN01_CLS_01"
30 = {HashMap$Entry@18294} "XMSC_WMQ_TEMP_Q_PREFIX" ->
31 = {HashMap$Entry@18295} "XMSC_WMQ_RECEIVE_ISOLATION" -> "0"
32 = {HashMap$Entry@18296} "XMSC_WMQ_POLLING_INTERVAL" -> "5000"
33 = {HashMap$Entry@18297} "XMSC_CONNECTION_TYPE" -> "1"
34 = {HashMap$Entry@18298} "XMSC_WMQ_QUEUE_MANAGER" -> "USTCMN01"
35 = {HashMap$Entry@18299} "XMSC_WMQ_PROCESS_DURATION" -> "0"
36 = {HashMap$Entry@18300} "XMSC_WMQ_CLONE_SUPPORT" -> "0"
37 = {HashMap$Entry@18301} "XMSC_WMQ_SSL_CIPHER_SUITE"
..............
........
48 = {HashMap$Entry@18312} "XMSC_ADMIN_OBJECT_TYPE" -> "20"
..........
............