View previous topic :: View next topic |
Author |
Message |
Dip Beginner
Joined: 24 Mar 2006 Posts: 27 Topics: 14
|
Posted: Thu Jun 14, 2007 9:05 pm Post subject: Selective read from a MQ |
|
|
Hi,
Can i read (COBOL-MQ program) messages selectively from a MQ?
Let say i have 5 messages in a MQ
AAAAA--------------$$------Record---------1
ABABA--------------AN------Record---------2
ABABA--------------AA------Record----------3
ABABX--------------$$------Record----------4
AXCSV--------------SA------Record---------5
I want to read and write messages 1 and 4($$ is the identifier) into a flat file from the MQ and leave the messages 2, 3 and 5 back in the MQ.
Thanks!
Dip. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Fri Jun 15, 2007 6:36 am Post subject: |
|
|
if the messages are indexed, yes. Indexing for the queue must be ON, because that affects the original PUT.
If they are not indexed, best you can do is do a destructive read, write to qsam what you want and those that you don't want rewrite to the queue. Before you start the process, you need to know how many items are on the queue, and just perform the read/write cycle that many times. But if the queue is constantly being PUTed by another source, you are going to have to identify and save the first queue item that you PUT so that when you GET it again, you know to stop. This means commit every get.
another way is to use the MQS management utility and copy all items to a work queue and process that queue with your program.
DFSORT canl browse the queue, you can access the items you want, but they all will stay on the queue.
If this is a production requirement, that different msgs are processed by different subsystems, your queue design is very poor.
You could improve the present queue structure design by writting a module that does destructive reads on the current catch-all queue and redistributes msgs based on criteria to 'new' queues which can be read destructively by their appropriate sub-system - thus you would not have to endure the silliness that the original design has provided. _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
bob_buxton Beginner

Joined: 20 Dec 2002 Posts: 44 Topics: 0 Location: Hampshire, England
|
Posted: Fri Jun 15, 2007 7:21 am Post subject: |
|
|
If you can arrange to have your selection field into Correlid or Groupid fields of the MQMD header when the messages are put you can then get messages by Correlid/Groupid.
If that is not feasible you can Browse the queue and then do a get with MQGMO_GET_MESSAGE_UNDER_CURSOR to remove messages of interest from the queue _________________ Bob Buxton
Ex Websphere MQ for zOS development |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Fri Jun 15, 2007 7:27 am Post subject: |
|
|
bob_buxton,
great post, thx.
when did MQGMO_GET_MESSAGE_UNDER_CURSOR become effective? _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
|
Back to top |
|
 |
|
|