ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » MQ Java API question

Post new topic  Reply to topic
 MQ Java API question « View previous topic :: View next topic » 
Author Message
ydsk
PostPosted: Wed Jan 09, 2008 11:00 am    Post subject: MQ Java API question Reply with quote

Chevalier

Joined: 23 May 2005
Posts: 410

We have a session bean running on WAS that has a bunch of methods involving MQ API ( people here didn't like JMS API because of issues related to message segmentation and so they are using MQ API completely ). Note that MQ has been installed and configured along with but independent of WAS on a Windows server.

Each of the methods in the session bean have a finally{ } block that contains a qmgr.close( ) followed by a qmgr.disconnect( ) methods as:

finally {
try {
qMgr.close();
qMgr.disconnect();
}
catch (MQException e2) {
e2.printStackTrace( new InternalLogPrintStream(log));
}
}

I couldn't find the close ( ) method in the published mq v6 java API.
Can someone pls tell me if it is a valid method to use on a qmgr object ?

The input count on a queue keeps going up until the box is rebooted and hence this post. I know this indicates a problem with the method that is doing a OPEN-for-GET.

Except for the close( ) method the java code looks very normal.

Appreciate if someone can explain it a bit.

Thanks.
Back to top
View user's profile Send private message
ydsk
PostPosted: Wed Jan 09, 2008 11:13 am    Post subject: Reply with quote

Chevalier

Joined: 23 May 2005
Posts: 410

Here is a method in the session bean that I suspect is causing the issue:
I think the queue should be closed instead of the qmgr. Someone please correct me if I am wrong.

public Hashtable getMQMessage(String moduleName) {

MQQueue myQueue = null;

try {
ht = new Hashtable();
ht.clear();

Properties mqProperties = new Properties();

//int openOptions = MQC.MQGMO_SYNCPOINT;
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING;

mqProperties.put(MQC.THREAD_AFFINITY_PROPERTY, new Boolean(true));
pr("getMQMessageFromOneSource: 3");
qMgr2 = new MQQueueManager("QM_CFMS_INT_JAVA", mqProperties);
pr("getMQMessageFromOneSource: 4");

if (moduleName.equalsIgnoreCase("FFMIA")){
myQueue = qMgr2.accessQueue("FFMIA.SCHEDULEDRES.QUEUE", openOptions, null, null, null);
}
else if (moduleName.equalsIgnoreCase("DFA")){
myQueue = qMgr2.accessQueue("DFA.SCHEDULEDRES.QUEUE", openOptions, null, null, null);
}
else if (moduleName.equalsIgnoreCase("UM")){
myQueue = qMgr2.accessQueue("UM.SCHEDULEDRES.QUEUE", openOptions, null, null, null);
}

pr("getMQMessageFromOneSource: After accessing queue");
MQGetMessageOptions gmo = new MQGetMessageOptions();
pr("getMQMessageFromOneSource: 5");
gmo.options = MQC.MQGMO_SYNCPOINT + MQC.MQGMO_COMPLETE_MSG + MQC.MQGMO_CONVERT;
pr("getMQMessageFromOneSource: 6");
MQMessage myMessage = new MQMessage();
myMessage.clearMessage();
myMessage.correlationId = MQC.MQCI_NONE;
myMessage.messageId = MQC.MQMI_NONE;
//myMessage.setVersion(MQC.MQMD_VERSION_2);

pr("getMQMessageFromOneSource: 7");
myQueue.get(myMessage, gmo);
//String message = myMessage.readLine();
String message = myMessage.readString(myMessage.getMessageLength());
pr("the message = " + message);

if (message != null) {
String jobID = myMessage.applicationIdData.trim();
if (moduleName.equalsIgnoreCase("FFMIA"))
{
System.out.println("jobID is "+jobID);
int jobIDSize = jobID.length();
System.out.println("jobIDSize is "+jobIDSize);
if (jobIDSize >= 32)
{
String newJobID = jobID.substring(0, + "-" + jobID.substring(8,12) + "-" + jobID.substring(12,16) + "-" + jobID.substring(16,20) + "-" + jobID.substring(20);
System.out.println("new JobID is "+newJobID);
jobID = newJobID;
}
else
System.out.println("JOBID does not match the expected length "+jobID);
}
pr("getMQMessageFromOneSource: job id = " + jobID);
pr("getMQMessageFromOneSource: before hashtable put");
pr("getMQMessageFromOneSource: message = " + message);

ht.put(jobID, message);
pr("getMQMessageFromOneSource: ht = " + ht.toString());
}
}
catch (IOException i) {
//i.printStackTrace();
i.printStackTrace(new InternalLogPrintStream(log));
}
catch (MQException m) {
//m.printStackTrace();
m.printStackTrace(new InternalLogPrintStream(log));
}
catch (Exception e) {
//e.printStackTrace();
e.printStackTrace(new InternalLogPrintStream(log));
pr("getMQMessageFromOneSource: returning from MQException");
return ht;
}
finally {
try {
qMgr2.close();
qMgr2.disconnect();
}
catch (MQException e2) {
//e2.printStackTrace();
e2.printStackTrace(new InternalLogPrintStream(log));
}
}
return ht;

}
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jan 09, 2008 1:57 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Quote:
finally {
try {
qMgr2.close();
qMgr2.disconnect();
}
catch (MQException e2) {
//e2.printStackTrace();
e2.printStackTrace(new InternalLogPrintStream(log));
}
}


Your finally would need to look like:
Code:
 finally {
try {
qMgr2.close();
}catch (MQException e2) {
//e2.printStackTrace();
e2.printStackTrace(new InternalLogPrintStream(log));
}
try{
qMgr2.disconnect();
}
catch (MQException e2) {
//e2.printStackTrace();
e2.printStackTrace(new InternalLogPrintStream(log));
} finally{
qMgr2 = null;
}
}


Note that you might want more than just the stack trace (i.e. the Exception message etc... more specifically the reason code)
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
ydsk
PostPosted: Fri Jan 11, 2008 12:48 pm    Post subject: Reply with quote

Chevalier

Joined: 23 May 2005
Posts: 410

Hi fjb_saper,

Is close( ) a valid method on a qmgr object ?

Thanks.
ydsk.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Jan 11, 2008 12:55 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

ydsk wrote:
Hi fjb_saper,

Is close( ) a valid method on a qmgr object ?

Thanks.
ydsk.

Sorry I am more used to JMS. In java base it might be disconnect()...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
JLRowe
PostPosted: Sat Jan 12, 2008 1:43 am    Post subject: Reply with quote

Yatiri

Joined: 25 May 2002
Posts: 664
Location: South East London

I would re-investigate use of the JMS API.

There are a number of issues when using the base java API in WAS (or any other J2EE container for that matter).

There are issues with XA transactions, threads, pooling and security that you should be aware of detailed in this document:

http://www-1.ibm.com/support/docview.wss?rs=171&context=SSFKSJ&dc=DB520&uid=swg21266535&loc=en_US&cs=UTF-8&lang=en&rss=ct171websphere
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » MQ Java API question
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.