Author |
Message
|
nehamagarde |
Posted: Wed Jan 02, 2019 4:11 am Post subject: Message committed later left unread with BROWSE_NEXT option |
|
|
Newbie
Joined: 02 Jan 2019 Posts: 3
|
Program Background:
In a reader program, we use MQGET API for browsing messages on queue with option BROWSE_NEXT. Multiple processes write messages on the queue from which the reader program browses.
At a later point of time based on some condition the messages will be deleted from queue.
Problem statement:
For a particular scenario, two processes write messages on the queue where reader program browses. One process puts message on queue but takes a little while to commit the XA transaction. Simultaneously a second process puts a message on the queue and commits (this will be the second message on the queue after the uncommitted one).
With BROWSE_NEXT option, the reader program skips the uncommitted message and browses the second message which was committed. Now when first process commits the message on queue it remains unread as the reader process reads with BROWSE_NEXT and the cursor is past the second message.
We tried to do a BROWSE_FIRST, but this solution doesn’t work as it may result in the same message being read twice.
Is there any way to know whether a particular message (maybe some get message option) was already browsed and shouldn’t be browsed again? |
|
Back to top |
|
 |
bruce2359 |
Posted: Wed Jan 02, 2019 5:25 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
|
Back to top |
|
 |
hughson |
Posted: Thu Jan 03, 2019 1:24 am Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
You have described the classic problem that Browse with Mark was invented to solve.
Use the following options instead of your MQGMO_BROWSE_FIRST then MQGMO_BROWSE_NEXT:-
Code: |
MQGMO_BROWSE_FIRST +
MQGMO_UNMARKED_BROWSE_MSG +
MQGMO_MARK_BROWSE_HANDLE +
MQGMO_WAIT |
Or the handy constant defined in cmqc.h:-
Code: |
MQGMO_BROWSE_HANDLE +
MQGMO_WAIT |
If you have multiple readers, look into Cooperative Browse as well.
For more information check out this Slide Share presentation.
WebSphere MQ V7 API Enhancements (starting at page 49)
Cheers,
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
nehamagarde |
Posted: Thu Jan 03, 2019 2:41 am Post subject: |
|
|
Newbie
Joined: 02 Jan 2019 Posts: 3
|
Thanks for the suggestion and it is now working as expected.
The program was also using option MQGMO_COMPLETE_MSG along with BROWSE_NEXT/BROWSE_FIRST.
With options MQGMO_UNMARKED_BROWSE_MSG and MQGMO_MARK_BROWSE_HANDLE it is suggested that we cannot use MQGMO_COMPLETE_MSG. Is there any impact on not using MQGMO_COMPLETE_MSG option while browsing? |
|
Back to top |
|
 |
hughson |
Posted: Thu Jan 03, 2019 3:13 am Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
Are you using segmented messages for this application?
If not, don't worry about MQGMO_COMPLETE_MSG. It is only necessary in order to ask the queue manager to re-assemble the segments of a message that was segmented.
Cheers,
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
nehamagarde |
Posted: Tue Jan 08, 2019 3:04 am Post subject: |
|
|
Newbie
Joined: 02 Jan 2019 Posts: 3
|
Thanks for information.
Above solution is working for us.
We are not using segmented message in our application. |
|
Back to top |
|
 |
hughson |
Posted: Tue Jan 08, 2019 2:46 pm Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
|
Back to top |
|
 |
|