|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Get with Wait |
« View previous topic :: View next topic » |
Author |
Message
|
mpalmer |
Posted: Fri Sep 24, 2004 9:01 am Post subject: Get with Wait |
|
|
Novice
Joined: 25 Mar 2002 Posts: 24 Location: New Jersey, USA
|
Below I have copied my sample Java Get program. It appears to me that the get with wait option is not working, based on the displays that I have in the program. Can you tell me what is wrong? Much appreciate your help.
/*
* Created on Sep 17, 2004
*/
/**
* @author MI299D
*/
import java.io.*;
import java.util.*;
import com.ibm.mq.*; // Include the WebSphere MQ classes for Java package
import java.text.*;
public class MQGet2
{
private String qManager = "TST_QM_PALMER";
private MQQueueManager qMgr;
public static void main(String[] args)
{
new MQGet2();
}
public MQGet2()
{
try
{
// Create a connection to the queue manager
qMgr = new MQQueueManager(qManager);
// Set up the options on the queue we wish to open
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF|
MQC.MQOO_OUTPUT;
// Now specify the queue that we wish to open & the open options
MQQueue system_default_local_queue =
qMgr.accessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE",openOptions);
// Define a simple message & write text in UTF format
MQMessage hello_world = new MQMessage();
hello_world.writeUTF("Hello World!");
// specify the msg options
MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the defaults
// put the msg on the queue
system_default_local_queue.put(hello_world,pmo);
// get the msg back again
// first define a MQ message buffer to receive the msg into
MQMessage retrievedMessage = new MQMessage();
retrievedMessage.messageId = hello_world.messageId;
// Set the get message options
MQGetMessageOptions gmo = new MQGetMessageOptions(); // accept defaults
gmo.options = MQC.MQGMO_WAIT;
gmo.waitInterval = 90000;
// get the date/timestamp & display it
Date today3;
today3 = new Date();
System.out.println("*** Maria - about to get msg off q " + today3);
// get the msg off the queue
system_default_local_queue.get(retrievedMessage, gmo);
// get the date/timestamp & display it
Date today;
today = new Date();
System.out.println("*** Maria - got msg " + today);
// And prove we have the message by displaying the UTF message text
String msgText = retrievedMessage.readUTF();
System.out.println("The message is: " + msgText);
// close the queue
system_default_local_queue.close();
// get the date/timestamp & display it
Date today2;
today2 = new Date();
System.out.println("*** Maria - close q " + today2);
// Disconnect from the qmgr
qMgr.disconnect();
}
// If an error occurred in the above, try to identify what went wrong.
catch (MQException ex)
{
System.out.println("A WebSphere MQ error occurred : Completion code " + ex.completionCode +
" Reason code " + ex.reasonCode);
}
// was it a Java buffer space error?
catch (java.io.IOException ex)
{
System.out.println("An error occurred while writing to the message buffer: " + ex);
}
} // end of start
} // end of program |
|
Back to top |
|
 |
vennela |
Posted: Fri Sep 24, 2004 9:45 am Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
Hi
I tried to compile and run your program and it is working just fine. What do you think is not working.
Get with wait means:
An MQGET call is issued and if a message within the wait_interval arrives on the queue then that message will be get otherwise the QMGET call ends.
It DOES NOT mean that the it will GET after the specified wait interval. If you want to do that you have to induce a sleep in your program. |
|
Back to top |
|
 |
mpalmer |
Posted: Fri Sep 24, 2004 10:09 am Post subject: |
|
|
Novice
Joined: 25 Mar 2002 Posts: 24 Location: New Jersey, USA
|
here's my problem - I am sending a batch file from a UNIX server to a mainframe server. Say the file has 100 records in it. The commit point on the put program from the UNIX app is 10. 10 records make it to the destination queue. Triggering is on, and the get job is kicked off. The 10 records are retrieved from the queue. Due to communication issues, the other 90 are held up in the hub. What will the get job on the mainframe do if it is using get with wait....will it get the 10 records, then wait the specified wait interval to see if more messages will come to the destination queue, then close? I am not sure I understand the purpose of the wait interval. |
|
Back to top |
|
 |
vennela |
Posted: Fri Sep 24, 2004 10:35 am Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
Quote: |
will it get the 10 records, then wait the specified wait interval to see if more messages will come to the destination queue, then close? |
That is what will exactly happen if you loop and do GETs for messages. |
|
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
|
|
|
|