|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Put Date/Time not updating |
« View previous topic :: View next topic » |
Author |
Message
|
paulfitz |
Posted: Mon Oct 11, 2004 2:14 am Post subject: Put Date/Time not updating |
|
|
Newbie
Joined: 15 Jun 2004 Posts: 8
|
I have the following functionality in my app, a message comes into our in queue and we read it, the first thing we do is write a copy of it to our audit queue then we process it. After processing it we write a new message to our out queue and finally a copy to our out audit queue. The problem is that the put date time on all the messages is the same (and our app may be quick but it isn't that quick). I do copy some values from the incoming message that may affect this but commenting them out is becoming a bit hit and miss (I've pasted in a copy of the code below) and I have tried setting the putDateTime but no luck,
MQMessage outgoingMsg = new MQMessage();
//Audit
MQMessage replyAuditMsg = new MQMessage();
outgoingMsg.write(response.getMessage());
replyAuditMsg.write(response.getMessage());
...
outgoingMsg.priority = incomingMsg.priority;
outgoingMsg.messageId = incomingMsg.messageId;
outgoingMsg.correlationId = incomingMsg.messageId;
outgoingMsg.groupId = incomingMsg.groupId;
outgoingMsg.format = incomingMsg.format;
outgoingMsg.messageType = MQC.MQMT_REPLY;
// Put this in but changed nothing
outgoingMsg.putDateTime = new GregorianCalendar();
...
//Audit Reply Copy
//Can't use the message object so create a copy
replyAuditMsg.expiry = auditExpiryTime;
replyAuditMsg.priority = outgoingMsg.priority;
replyAuditMsg.messageId = outgoingMsg.messageId;
replyAuditMsg.correlationId = outgoingMsg.correlationId;
replyAuditMsg.groupId = outgoingMsg.groupId;
replyAuditMsg.format = outgoingMsg.format;
replyAuditMsg.persistence = MQC.MQPER_PERSISTENCE_AS_Q_DEF;
replyAuditMsg.putDateTime = outgoingMsg.putDateTime;
//Create the Reply Audit Queue
MQQueue replyAuditQueue = qManager.accessQueue(replyAuditq, WRITE_OPEN_OPTIONS);
//Set up the putOptions for the Reply Audit Message
MQPutMessageOptions putOptions = new MQPutMessageOptions();
putOptions.options = PUT_AUDIT_OPTIONS;
putOptions.contextReference = inputQueue;
//Add the message to the Reply Audit Queue
replyAuditQueue.put(replyAuditMsg, putOptions);
replyAuditQueue.close();
Thanks in advance for any help,
Paul Fitz. |
|
Back to top |
|
 |
RogerLacroix |
Posted: Mon Oct 11, 2004 9:50 am Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Hi,
You didn't show us PUT_AUDIT_OPTIONS or WRITE_OPEN_OPTIONS but when I see this line:
Code: |
putOptions.contextReference = inputQueue; |
I know that you are setting context. Stopping setting context and your problem will go anyway.
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
paulfitz |
Posted: Tue Oct 12, 2004 2:54 am Post subject: |
|
|
Newbie
Joined: 15 Jun 2004 Posts: 8
|
Thanks for the advice. I've stopped setting the context but now my messages show an Invalid Date Time in MQExplorer. I've tried setting the put time via the gregoian calendar and just not setting it at all (which is what I expected would work as I assumed MQ would handle when the message is put).
Paul. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Oct 12, 2004 10:03 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
[quote=paulfitz] my messages show an Invalid Date Time in MQExplorer[/quote]That's a know bug. Remember date and time are stored in UTC.
 |
|
Back to top |
|
 |
RogerLacroix |
Posted: Tue Oct 12, 2004 2:53 pm Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Hi,
The time looks fine in both MQ Explorer's 'Message Browser' window and 'Properties' window.
Here's a simple Java program that I tested it with:
Code: |
/**
* Program Name MQWrite
*
* Description This java class will read a line of input from the keyboard and send it as a message.
* The program will loop until the user presses CTL^Z.
*
* Sample Command Line Parameters
* -h 127.0.0.1 -p 1414 -c CLIENT.CHANNEL -m MQA1 -q TEST.QUEUE
*
* @author Copyright(C), Roger Lacroix, Capitalware
*
*/
import com.ibm.mq.*;
import java.util.Hashtable;
import java.io.*;
public class MQWrite
{
private Hashtable params = null;
public int port = 1414;
public String hostname;
public String channel;
public String qManager;
public String outputQName;
/**
* The constructor
*/
public MQWrite()
{
super();
}
/**
*
* @return
*/
private boolean allParamsPresent()
{
boolean b = params.containsKey("-h")
&& params.containsKey("-p") && params.containsKey("-c")
&& params.containsKey("-m") && params.containsKey("-q");
if (b)
{
try
{
port = Integer.parseInt((String) params.get("-p"));
}
catch (NumberFormatException e)
{
b = false;
}
// Set up MQ environment
hostname = (String) params.get("-h");
channel = (String) params.get("-c");
qManager = (String) params.get("-m");
outputQName = (String) params.get("-q");
}
return b;
}
/**
*
* @param args
* @throws IllegalArgumentException
*/
private void init(String[] args) throws IllegalArgumentException
{
params = new Hashtable(5);
if (args.length > 0 && (args.length % 2) == 0)
{
for (int i = 0; i < args.length; i += 2)
{
params.put(args[i], args[i + 1]);
}
}
else
{
throw new IllegalArgumentException();
}
if (allParamsPresent())
{
// Set up MQ environment
MQEnvironment.hostname = hostname;
MQEnvironment.channel = channel;
MQEnvironment.port = port;
}
else
{
throw new IllegalArgumentException();
}
}
/**
*
* @param args
*/
public static void main(String[] args)
{
MQWrite write = new MQWrite();
try
{
write.init(args);
write.write();
}
catch (IllegalArgumentException e)
{
System.out.println("Usage: java MQWrite <-h host> <-p port> <-c channel> <-m QueueManagerName> <-q QueueName>");
System.exit(1);
}
catch (MQException e)
{
System.out.println(e);
System.exit(1);
}
}
/**
*
* @throws MQException
*/
private void write() throws MQException
{
String line;
int lineNum = 0;
int openOptions = MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING;
MQQueueManager _qMgr = new MQQueueManager(qManager);
try
{
MQQueue queue = _qMgr.accessQueue(outputQName,
openOptions,
null, // default q manager
null, // no dynamic q name
null); // no alternate user id
DataInputStream input = new DataInputStream(System.in);
System.out.println("MQWrite v1.0 connected");
System.out.println("and ready for input, terminate with a blank line (or ^Z)\n\n");
MQMessage sendmsg = new MQMessage();
sendmsg.format = MQC.MQFMT_STRING;
sendmsg.feedback = MQC.MQFB_NONE;
sendmsg.messageType = MQC.MQMT_DATAGRAM;
MQPutMessageOptions pmo = new MQPutMessageOptions();
line = input.readLine();
while (!(line.equals("")) && (line != null))
{
sendmsg.messageId = MQC.MQMI_NONE;
sendmsg.correlationId = MQC.MQCI_NONE;
sendmsg.writeString(line);
// put the message on the queue
queue.put(sendmsg, pmo);
sendmsg.clearMessage();
System.out.println(++lineNum + ": " + line);
line = input.readLine();
}
queue.close();
_qMgr.disconnect();
}
catch (com.ibm.mq.MQException mqex)
{
System.out.println(mqex);
}
catch (java.io.IOException ioex)
{
System.out.println("An MQ IO error occurred : " + ioex);
}
}
} |
Regards,
Roger Lacroix _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
paulfitz |
Posted: Wed Oct 13, 2004 7:33 am Post subject: |
|
|
Newbie
Joined: 15 Jun 2004 Posts: 8
|
I've stripped down the code to the following
replyAuditMsg = new MQMessage();
replyAuditMsg.messageId = MQC.MQMI_NONE;
replyAuditMsg.correlationId = MQC.MQMI_NONE;
//Create the Reply Audit Queue
MQQueue replyAuditQueue = qManager.accessQueue(replyAuditq, WRITE_REPLY_AUDIT_OPEN_OPTIONS);
//Set up the putOptions for the Reply Audit Message
MQPutMessageOptions putOptions = new MQPutMessageOptions();
putOptions.options = PUT_REPLY_AUDIT_OPTIONS;
//Add the message to the Reply Audit Queue
replyAuditQueue.put(replyAuditMsg, putOptions);
replyAuditQueue.close();
where WRITE_REPLY_AUDIT_OPEN_OPTIONS and PUT_REPLY_AUDIT_OPTIONS equal,
WRITE_REPLY_AUDIT_OPEN_OPTIONS = MQC.MQOO_OUTPUT |
MQC.MQOO_BIND_AS_Q_DEF | MQC.MQOO_FAIL_IF_QUIESCING;
PUT_REPLY_AUDIT_OPTIONS = MQC.MQPMO_NO_CONTEXT | MQC.MQPMO_NO_SYNCPOINT | MQC.MQPMO_FAIL_IF_QUIESCING;
And I still get invalid date time (I tried using the options in your code to connect and got an exception). When I look at the message via the command line utility amqsbcg I get the following so I guess its not a problem with MQ Explorer but with the message itself,
PutDate : ' ' PutTime : ' '
Paul Fitz. |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed Oct 13, 2004 8:56 am Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Hi,
You got an exception. I just retested it to make sure I copied/pasted it correctly. It ran fine.
How are you running it? It should be like:
Code: |
java MQWrite -h 10.10.10.10 -p 1414 -c SYSTEM.DEF.SVRCONN -m MQA1 -q TEST.ROGER |
What is your exception?
Regards,
Roger Lacroix _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
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
|
|
|
|