Author |
Message
|
ping master |
Posted: Fri Jun 13, 2003 6:14 am Post subject: Backing up the Q file and then restoring it |
|
|
 Centurion
Joined: 20 Sep 2002 Posts: 116 Location: USA
|
XP/MQ ver 5.3
I notice within the ..\IBM\WEBSPHERE MQ\QMGRS\USERID\QUEUES
for each queue there is a file 'Q' that is 2k
if I write a simple put message program to simple drop messages in the DEAFULT.XMITQ i notice the file changes to lets say 16K
if I were to back up this file to different location, then rebuild the qmgr, can I then replace the 16K back .. this is to save data that has been queued up but needs a QM rebuild.. Anybody know if this is possible.
Currently I have it backing the file up, rebuilding the qmgr then restoring the file but when I do a get queuedepth for DEFAULT.XMITQ it says 0..
kinda strange because when I look at the actually folder the file is there 16K
****NOTE
back in the day, for the same scenario -Deafult.xmitq) on MQ ver2.1,
I used to back up the mqpers.mqi file to a different directory then rebuild the qmgr, then replace the mqpers.mqi file and Voila! the messages appeared in the defaultxmit queue, as soon as I start the sender channel the data is distributed. I need to do something similar in XP/ver 5.3 and would like to automate it, I think I'm close but I'm hitting a couple of snags
any ideas??
thanks alot
$PM |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jun 13, 2003 6:44 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
ping master |
Posted: Fri Jun 13, 2003 6:45 am Post subject: |
|
|
 Centurion
Joined: 20 Sep 2002 Posts: 116 Location: USA
|
thanks Jeff. I checked it out, and it appears that there is a log file that coincide with the data within a specified queue i.e. DEFAULT.XMITQ, however I am unable to find a log file that updates as I put messages into a queue. I think the files are in.. \IBM\Websphere MQ\\log\USERID\active
and they appear as
S0000000.LOG
S0000001.LOG
S0000002.LOG
but if i back up these three files and the Q data file in the default.xmitq then rebuild, then replace these files the queue manager wont start with an error of :AMQ7017 Log not available. huh???
any ideas??? thanks
$PM |
|
Back to top |
|
 |
pgorak |
Posted: Mon Jun 16, 2003 3:50 am Post subject: |
|
|
 Disciple
Joined: 15 Jul 2002 Posts: 158 Location: Cracow, Poland
|
Apart from data kept in log files, queue manager keeps information about the last syncpoint. You can find the location of this file in the documentation - see directory structure for you platform.
However, I would not recommend to use any manual procedures, apart from what is explained in the documentation on media recovery. Other discussions and tests presented in this forum have shown that you can go into serious trouble trying to perform recovery in other way
Piotr |
|
Back to top |
|
 |
mqonnet |
Posted: Mon Jun 16, 2003 5:30 am Post subject: |
|
|
 Grand Master
Joined: 18 Feb 2002 Posts: 1114 Location: Boston, Ma, Usa.
|
On many platforms you can do what you are trying to. Just moving the queue files and the data gets along with your queue files. But not on NT/2k.
The only way you could do is to record an image of the qm and then recover the image back and restore it onto the same or other qm.
Also bear in mind that you can do this only for Persistent messages and since they are PM, the messages are also logged into the logger. And from my understanding its only IBM who knows how this whole thing works internally and how the data is stored and co-related. Hence there would be no point in trying to manually copy and move the data within a queue or the queue itself.
Hope this helps.
Cheers
Kumar |
|
Back to top |
|
 |
ping master |
Posted: Mon Jun 16, 2003 7:20 am Post subject: |
|
|
 Centurion
Joined: 20 Sep 2002 Posts: 116 Location: USA
|
mqonnet,
how do you explain the way Kolban's MQJexplorer does it? It has a right click menu item that says back up to file, and it creates a file.dat then I can rebuild the qmgr and right click on a queue and click restore from file and it restores the messages perfectly?? I have tried it on xp/mq 5.3 works great .
I havent been able to get a hold of Neil to ask, but there is go to be an explanation, thats exactly what I need
thanks
$PM |
|
Back to top |
|
 |
mqonnet |
Posted: Mon Jun 16, 2003 7:34 am Post subject: |
|
|
 Grand Master
Joined: 18 Feb 2002 Posts: 1114 Location: Boston, Ma, Usa.
|
I dont know how MQJexplorer does this. But presumably it copies the queue name and the data that includes all the messages in raw format to a dat file and then reads off this file when creating a new queue. Just my guess.
Again, this is my understanding and i believe it is correct. But i may be wrong. But i believe on NT there is no way out other than that i mentioned to achieve what you were trying to.
Cheers
Kumar |
|
Back to top |
|
 |
Cliff |
Posted: Thu Jun 19, 2003 11:28 pm Post subject: |
|
|
Centurion
Joined: 27 Jun 2001 Posts: 145 Location: Wiltshire
|
MQJExplorer is one of a number of utilities which can back up queues to files. It is quite straightforward to write an application like this yourself - essentially you MQGET the messages from the queue, write them and their MQMDs to a file in binary mode, then commit the changes. Reloading the queue is the opposite process. Easy peasy in a language like C or PL/1.
Note that neither the base queue files nor the log files are used directly! That is NOT the way to go.
HTH -
Cliff |
|
Back to top |
|
 |
ping master |
Posted: Wed Aug 20, 2003 8:32 am Post subject: |
|
|
 Centurion
Joined: 20 Sep 2002 Posts: 116 Location: USA
|
i definitely understand how to use and MQGET and get the messages from the queue but I am somewhat confused about saving the MQMD part. I need the messages to go back in the exact order they were in before I took them off the queue. do you know where I can find snippet/example either in Java or C ?
here is what ive been working on in java:
Code: |
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = gmo.options + MQC.MQGMO_BROWSE_NEXT;
MQMessage myMessage = new MQMessage();
File f2 = new File("C:\\JAVA\\mqpers.dat");
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(f2));
while (true) {
myMessage.clearMessage();
myMessage.correlationId = MQC.MQCI_NONE; // must set to null
myMessage.messageId = MQC.MQMI_NONE; // after each call
browseQueue.get(myMessage, gmo);
j+=1;
byte[] dlmtr = {'*','*','*'};
byte[] b = new byte[myMessage.getMessageLength()];
myMessage.readFully(b);
bos.write(b);
bos.write(dlmtr);
bos.flush();
} //end while loop |
thanks! |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Aug 20, 2003 11:17 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
ping master wrote: |
I need the messages to go back in the exact order they were in before I took them off the queue. |
Then store them in the exact order you took them off the queue, and do your puts in the same order.
If you append your messages to a file sequentially as you get them, and then read the file from top to bottom and put each message in as you read it, this is done. The first message at the top of the file was the first message read off the queue, and is then the first message put back on the queue and thus the first message taken off again. |
|
Back to top |
|
 |
ping master |
Posted: Fri Aug 22, 2003 8:39 am Post subject: |
|
|
 Centurion
Joined: 20 Sep 2002 Posts: 116 Location: USA
|
correct. That seems pretty evident
its the MQMD part. the queue I am trying to backup and restore to is an XMIT queue. I guess Im just not being clear.. Ill try again
to pull the message out of the XMIT queue, you are saying do a simple get with no specail GMO options...write to a file (as a ..?) then a simple put?? there is nothing I else need to do? the format of the data is MQXMIT - do I need to convert ??
thanks for your replies. |
|
Back to top |
|
 |
EddieA |
Posted: Fri Aug 22, 2003 1:00 pm Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
The fact that the queue is an XMIT queue makes no real difference to the GET, except that an MCA would open the queue Exclusively.
Assuming that you can read the queue, then a simple GET will retrieve the message, which will actually contain the XMIT header followed by the original payload. The message length will be the total of the 2 pieces. You can then save the mesage as a BLOB (because the XMIT header contains both binary and character data). Unless you are planning on restoring the messages to an XMIT queue on a different platform that where you take them, I would NOT do a GET with Convert.
When you come to restore the messages to an XMIT queue, the only thing to remember is to set the Format correctly, as a XMIT header.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
ping master |
Posted: Tue Aug 26, 2003 5:57 am Post subject: |
|
|
 Centurion
Joined: 20 Sep 2002 Posts: 116 Location: USA
|
thanks Eddie, you obviously have a deep understanding of this and I appreciate your reply. So from the above code, reading the message by bytes and then writing to a text file will work fine. when putting the message back I only need to set it to MQXMIT instead of MQSTR. correct? it is that easy? im not too sure about the blob thing, you mean throwing it to a DB. i really need to just write the data to afile then restore it back to the xmit queue. thanks again |
|
Back to top |
|
 |
EddieA |
Posted: Tue Aug 26, 2003 6:50 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Not too sure of the correct terminology, but by 'blob' I meant that the data must be treated as bytes that can contain any hex value. You cannot use text, as that only covers some of the possible 256 hex values for each byte, and for the bytes that fall ouside this range can be 'changed' by writing and reading as text.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
|