|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Sending messages to a Distribution List using Java program |
« View previous topic :: View next topic » |
Author |
Message
|
jagan |
Posted: Tue Sep 24, 2002 3:34 am Post subject: Sending messages to a Distribution List using Java program |
|
|
Acolyte
Joined: 26 Jun 2001 Posts: 55
|
Hi All,
Iam getting Error message 2136, while iam trying to send a simple message through Distribution List. iam attaching the Java code below. As per the Docus it is saying we have to add MQOD fields. But i could not able to add those fields..
Can any one help me out of this...
Regards
Jagan
My code follows, I created two Queue Manager QM1, and QM2 and Local queues QM1.Local in QM1, and QM2.Local in QM2
and the argument is as below
"java MQPutDistributionList MQ1.LOCAL MQ1 MQ2.LOCAL MQ2"
import com.ibm.mq.*;
import java.util.Hashtable; // Required for properties
public class MQPutDistributionList {
private String qManager = "QM1";
private MQQueueManager qMgr;
MQDistributionListItem[] distrubutionListItems = new MQDistributionListItem[10] ;
MQDistributionList mdl ;
public static void main(String args[]) {
System.out.println("Now In main!!");
new MQPutDistributionList(args);
}
int k =1;
int x=0;
public MQPutDistributionList(String args[]) {
try {
for ( int i=0; i<10;i++) {
distrubutionListItems[i] = new MQDistributionListItem();
}
for ( int i=0; i<2;i++) {
distrubutionListItems[i].queueName = args[x];
System.out.println("QUEUE NAME"+args[x]);
x=x+2;
distrubutionListItems[i].queueManagerName =args[k];
System.out.println("QUEUE MANAGER"+args[k]);
k=k+2;
}
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING ;
MQMessage hello_world = new MQMessage();
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.recordFields=MQC.MQPMRF_MSG_ID |MQC.MQPMRF_CORREL_ID;
hello_world.writeUTF("Second ...Test message Put and Get ... ");
qMgr = new MQQueueManager(qManager);
mdl = qMgr.accessDistributionList(distrubutionListItems,openOptions);
mdl.put(hello_world,pmo);
mdl.close();
qMgr.close();
qMgr.disconnect();
}catch (MQException ex) {
System.out.println("An MQSeries error occurred : Completion code " +
ex.completionCode + " Reason code " + ex.reasonCode);
}
catch (java.io.IOException ex)
{
System.out.println("An error occurred whilst writing to the message buffer: " + ex);
}
}
} |
|
Back to top |
|
 |
jagan |
Posted: Thu Sep 26, 2002 1:13 am Post subject: Sending messages to a Distribution List using Java program |
|
|
Acolyte
Joined: 26 Jun 2001 Posts: 55
|
Grand Master can you help me out of theser.. |
|
Back to top |
|
 |
bduncan |
Posted: Thu Sep 26, 2002 8:58 am Post subject: |
|
|
Padawan
Joined: 11 Apr 2001 Posts: 1554 Location: Silicon Valley
|
Well, this may just be a typo in your post, but it seems there is a mistake on the line you are using to invoke the program. You wrote:
Quote: |
"java MQPutDistributionList MQ1.LOCAL MQ1 MQ2.LOCAL MQ2" |
But right above that you say your queue managers are QM1 and QM2. Plus in the code itself it is trying to connect to QM1, not "MQ1".
Another problem. You are defining your distribution list as an array of 10 before you know how many queues the user has actually specified on the command line. I think that the MQ API is looking at this, successfully opening the first 2 queues (because you passed those in from the command line) but on the third array index it is failing to open the queue because there is nothing in that array index. You need to either trim the array once you've filled it up, or define it with a length equal to the number of arguments (qmgr/qname pairs) passed in.
You also failed to tell us which Completion Code you got. This is important because in a 2136 error, if you also have a CompCode of MQCC_WARNING, this means some of the MQOPENs succeeded, but not all of them - which would indicate my theory about your array list being too long is correct. If the CompCode is MQCC_FAILED, this means none of the MQOPENs succeeded, which would indicate a more serious error in the code...
Hope this gets your problem fixed...  _________________ Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator |
|
Back to top |
|
 |
jagan |
Posted: Fri Sep 27, 2002 2:14 am Post subject: |
|
|
Acolyte
Joined: 26 Jun 2001 Posts: 55
|
Thanks, bduncan...
Yes, it was typo.. (it is "java QM1.LOCAL QM1 QM2.LOCAL QM2")
I am changed my earliest code as below
MQDistributionListItem[] distrubutionListItems = new MQDistributionListItem[2] ;
for ( int i=0; i<2;i++) {
distrubutionListItems[i] = new MQDistributionListItem();
distrubutionListItems[i].queueName = args[x];
System.out.println("QUEUE NAME"+args[x]);
x=x+2;
distrubutionListItems[i].queueManagerName =args[k];
System.out.println("QUEUE MANAGER"+args[k]);
k=k+2;
}
After that iam getting below exception ..
MQJE001: Completion Code 2, Reason 2197 |
|
Back to top |
|
 |
jagan |
Posted: Tue Oct 01, 2002 2:15 am Post subject: |
|
|
Acolyte
Joined: 26 Jun 2001 Posts: 55
|
|
Back to top |
|
 |
oz1ccg |
Posted: Mon Oct 07, 2002 12:15 am Post subject: |
|
|
 Yatiri
Joined: 10 Feb 2002 Posts: 628 Location: Denmark
|
jagan,
have you tried look 2197 in your manual ?
Quote: |
2197 MQRC_UNKNOWN_DEF_XMIT_Q
Unknown default transmission queue.
An MQOPEN or MQPUT1 call was issued specifying a
remote queue as the destination. If a local
definition of the remote queue was specified, or if a
queue-manager alias is being resolved, the XmitQName
attribute in the local definition is blank.
Because there is no queue defined with the same name
as the destination queue manager, the queue manager
has attempted to use the default transmission queue.
However, the name defined by the DefXmitQName
Corrective Action: Correct the queue definitions, or
the queue-manager attribute. See the MQSeries
Application Programming Guide for more information. |
And why are you getting that, this might be because you are refering a unknown qmgr....
just my $0.02  _________________ Regards, Jørgen
Home of BlockIP2, the last free MQ Security exit ver. 3.00
Cert. on WMQ, WBIMB, SWIFT. |
|
Back to top |
|
 |
jagan |
Posted: Mon Oct 07, 2002 2:17 am Post subject: |
|
|
Acolyte
Joined: 26 Jun 2001 Posts: 55
|
Thanks oz1ccg,
I found the problem in my code.. I tryed to put a message on two different local queues of two different queue managers. with using the remote queue definitions..
It really a folish thing )
Thanks for all master.. |
|
Back to top |
|
 |
oz1ccg |
Posted: Mon Oct 07, 2002 3:41 am Post subject: |
|
|
 Yatiri
Joined: 10 Feb 2002 Posts: 628 Location: Denmark
|
Happy to hear,
I find the reason codes quite good and together with the explanation in the manual very good. It's also the feedback I get from my MQ students af a programming course....
But it requires that we open the Reason code book...... and that is the hard part.
Just my $0.02  _________________ Regards, Jørgen
Home of BlockIP2, the last free MQ Security exit ver. 3.00
Cert. on WMQ, WBIMB, SWIFT. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|