Author |
Message
|
nithindoe |
Posted: Fri Jun 19, 2009 8:56 pm Post subject: Browse a Queue in random-Help plz... |
|
|
Newbie
Joined: 18 Jun 2009 Posts: 3
|
Hi i want to browse an MQ queue randomly. Suppose if I have 10 messages i want to access the 5th message without starting browsing from first element itself just like accessing arrays in C or Java. Is there any way to do this...
Plz help me out...... |
|
Back to top |
|
 |
Vitor |
Posted: Sat Jun 20, 2009 12:41 am Post subject: Re: Browse a Queue in random-Help plz... |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
nithindoe wrote: |
Is there any way to do this... |
Firstly - no there isn't. You'll have to browse from the first down.
Secondly - I don't know about Java, but in C if you write a single line of code that accesses the 5th element of an array, internally it starts from the first element and works forward. Obviously in both languages it's simply memory elements so it's really, really fast.
Thirdly - why do you want to do this? It's a very poor design, aside from the performance issues (both because WMQ browsing is inefficient and you'll need a lot of browse on a deep queue). You should be reading the first message on the queue (which might not physically be the first one) or a specific one (like a reply to a request you've issued). _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
nithindoe |
Posted: Sat Jun 20, 2009 9:54 am Post subject: |
|
|
Newbie
Joined: 18 Jun 2009 Posts: 3
|
hi i have a large queue and i need to browse it and display the messages in a webpage. the number of messages displayed at a time will depend on the value selected by user. So if the user select 10 first 10 messages wwill be displayed. then if he clicks next i have to show the next 10 messages. For this i have to again browse from the first one. when the queue is long it results in some perfomance issues.
How can i correct it??? |
|
Back to top |
|
 |
bruce2359 |
Posted: Sat Jun 20, 2009 10:02 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9470 Location: US: west coast, almost. Otherwise, enroute.
|
From your narrative, I'll assume the same end-user wants the next 10 messages. After your app displays the first 10 messages, retain the browse cursor, then do a browse next. You don't need to start at the beginning of the queue.
Please read the WMQ Application Programming Reference for MQGET and all the MQGMO options. _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
Vitor |
Posted: Sat Jun 20, 2009 10:53 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
nithindoe wrote: |
i need to browse it and display the messages in a webpage. the number of messages displayed at a time will depend on the value selected by user. |
It's an odd requirment, and bad practice to use a queue like this. If you need to examine a queue like this, load the messages into a database.
If it's just an administrative thing, use one of the existing support pacs.
If you adopt the suggestion of my associate, be sure to watch thread issues and queue handles. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
nithindoe |
Posted: Sat Jun 20, 2009 8:20 pm Post subject: |
|
|
Newbie
Joined: 18 Jun 2009 Posts: 3
|
ok i'll try it..
thanks 4 ur replies |
|
Back to top |
|
 |
gbaddeley |
Posted: Sun Jun 21, 2009 4:29 pm Post subject: Re: Browse a Queue in random-Help plz... |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
Vitor wrote: |
Secondly - I don't know about Java, but in C if you write a single line of code that accesses the 5th element of an array, internally it starts from the first element and works forward. Obviously in both languages it's simply memory elements so it's really, really fast. |
Accessing elements of arrays in high level languages is truely random, it doesn't need to start from the first element and work forward, so I don't really understand your statement. _________________ Glenn |
|
Back to top |
|
 |
gbaddeley |
Posted: Sun Jun 21, 2009 4:38 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
nithindoe wrote: |
hi i have a large queue and i need to browse it and display the messages in a webpage. the number of messages displayed at a time will depend on the value selected by user. So if the user select 10 first 10 messages wwill be displayed. then if he clicks next i have to show the next 10 messages. For this i have to again browse from the first one. when the queue is long it results in some perfomance issues.
How can i correct it??? |
The best solution is to browse the queue in FIFO order "on demand" and store the Message Ids in an array (assuming they are unique). eg. if they first need messages 51-60, browse 1-60 and store MsgIds for all of them, and only get the message data for 51-60. If they scroll back to display 41-50, get the message data using the stored Message Ids. If they scroll forward to 61-70, start browsing and storing Message Ids again "on demand". Basically you are progressively building a cache of Message Ids. This technique will be efficient for large queue depths and large messages. If there are <100 message on the queue at any time and they are <10K long each, it is probably easier to just browse the whole queue each time. Mind you, if any other process is destructively removing messages at the time, my "on demand" method won't work. _________________ Glenn |
|
Back to top |
|
 |
|