Author |
Message
|
kun.leeing |
Posted: Fri Feb 13, 2009 12:13 am Post subject: Dynamic Queue Access Problem |
|
|
 Disciple
Joined: 27 Sep 2008 Posts: 171
|
Hi,friends.
There's a problem about usage of dynamic queue.
I want to use the dynamic queue to serve the clients and solve the problem of limitation of connections. All messages for one client will be sent to its own queue removed as app quits.
But the code used to operate queue existed and made a little change for dynamic queue seems can not work correctly.
receiver:
Code: |
int openOptions = MQC.MQOO_INPUT_SHARED;
MQQueue myQueue = qMgr.accessQueue(modelqueuename, openOptions, qManager, "myqueue", null);
do {
try {
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = MQC.MQGMO_WAIT;
MQMessage myMessage = new MQMessage();
myQueue.get(myMessage, gmo);
String msg = myMessage.readString(myMessage.getMessageLength());
System.out.println("Browsed message: " + msg);
} catch (MQException ex) {
//error code
} catch (java.io.IOException ex) {
//error code
}
Thread.sleep(1);
} while (!done);
|
sender:
Code: |
int openOptions = MQC.MQOO_INPUT_SHARED | MQC.MQOO_OUTPUT;
MQQueue queue = qMgr.accessQueue("myqueue", openOptions, qManager, null, null);
//MQQueue queue = qMgr.accessQueue(modelqueuename, openOptions, qManager, "myqueue", null); //[color=red]if using this line, it'll throw the error 2100[/color]
MQPutMessageOptions pmo = new MQPutMessageOptions();
queue.put(msg, pmo); |
Firstly, I run the receiver let it create the queue and then sender will be run to send message to the temporary queue named of "myqueue".
The sender throws error 2042.
How can I solve this problem and make two ends intercommunicate rightly?
thanks
lee |
|
Back to top |
|
 |
Vitor |
Posted: Fri Feb 13, 2009 1:32 am Post subject: Re: Dynamic Queue Access Problem |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
kun.leeing wrote: |
Firstly, I run the receiver let it create the queue and then sender will be run to send message to the temporary queue named of "myqueue".
The sender throws error 2042. |
Yes, it will do. You seriously need to re-read up on dynamic queues and think about what you've designed and how it's reacting. Especially what the 2042 error is telling you.
kun.leeing wrote: |
How can I solve this problem and make two ends intercommunicate rightly? |
By using dynamic queues in a more conventional way.
I remain unconvinced this will resolve any connection problem you're having. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kun.leeing |
Posted: Fri Feb 13, 2009 6:06 am Post subject: |
|
|
 Disciple
Joined: 27 Sep 2008 Posts: 171
|
Thanks for your reply, vitor.
I know that 2042 means MQRC_OBJECT_IN_USE and if dynamic queue can not be used by two clients together?
But why the code can works correctly when change the dynamic queue to a local queue? I thought if my openOptions have not been configured aright.
Is there any demo I can use for reference ? Could you give me a clue?
What I thought is by using dynamic queue or local queue, a client can hold one connection with mq server.
All of messages previously from some different topics by using multi consumers can converge to a certain queue and the client can touch the messages from the queue, though this will need a app distributing messages on mq server.
Could you give me some suggestions?
Thanks. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Feb 13, 2009 9:52 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
kun.leeing wrote: |
Thanks for your reply, vitor.
I know that 2042 means MQRC_OBJECT_IN_USE and if dynamic queue can not be used by two clients together?
But why the code can works correctly when change the dynamic queue to a local queue? I thought if my openOptions have not been configured aright.
Is there any demo I can use for reference ? Could you give me a clue?
What I thought is by using dynamic queue or local queue, a client can hold one connection with mq server.
All of messages previously from some different topics by using multi consumers can converge to a certain queue and the client can touch the messages from the queue, though this will need a app distributing messages on mq server.
Could you give me some suggestions?
Thanks. |
Have you checked the attributes of the model queue underlying your dynamic queue? It probably has the noshare attribute.
In order to make the dynamic queue sharable you need to build if off a model queue that has the sharable attribute.
The really underlying question here is one of design. Why would you need to share the dynamic queue. What do you use it for? You realize of course that the lifetime of the dynamic temporary queue is the lifetime of the session right (JMS) ?
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kun.leeing |
Posted: Sat Feb 14, 2009 1:23 am Post subject: |
|
|
 Disciple
Joined: 27 Sep 2008 Posts: 171
|
Thanks,saper.
You're always so helpful.
I'll look into docs for more details, thanks. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Feb 14, 2009 10:23 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
fjb_saper wrote: |
The really underlying question here is one of design. Why would you need to share the dynamic queue. What do you use it for?
Have fun  |
_________________ MQ & Broker admin |
|
Back to top |
|
 |
kun.leeing |
Posted: Sat Feb 14, 2009 8:36 pm Post subject: |
|
|
 Disciple
Joined: 27 Sep 2008 Posts: 171
|
Thanks,saper.
By using dynamic queue, I just wonder if I can change my previous design that clients using pub/sub from multi different topics filter their msg and this must have many consumers and sessions for one client if I want excellent performance.
But If consumers're created by one session,bad processing efficiency comes.
My problem is the balance between performance and resources.
But now I don't find the solution for controling the priority of consumers effectively.
Could you tell me how to share the performance between consumers on one session?
The first consumer created by the session always possess of the highest performance. The others will be low.
So I thought the client using queue related to it hold one session and different messages converge to it.
This may decrease the connection number in system and the dispatching app on server should be demanded. So I have to make a new app dispatching msg on server for this.
I knew I can use existed queue by administrating method. But the number of clients is so large and not fixed.
So I thought about dynamic queue for my problem by some method of saving temporary messages.
Could you give me some suggestions based on my App?
thanks
lee |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Feb 15, 2009 7:02 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Well you have to be aware of multiple facts:
- The connection / session serializes the delivery of messages (read it up in the manuals). So in order to have real great performance there is no way around having at least 1 connection per client / 1 connection per MDB / 1 connection per subscriber.
So take a good look at your app and determine the max number of connections you think it is going to call for... Make sure this will fit your maxactive channels setting and connection pool settings (WAS).
- When using multiple clients to connect to the same queue to retrieve messages, the best performance is achieved if the clients are all under syncpoint (transacted sessions). Mixing transactional mode will deteriorate performance (see article in developerworks?)
- Because establishing a connection is expensive WAS creates a pool of connections that are being allocated at runtime to the process requesting it. The same way WAS has a little buffer of dynamic queues.
- Temporary dynamic queues cannot be used for persistent messages.
Their typical use is for request/reply on non persistent messages or subscription for non persistent messages and non durable subscriptions.
Hope this helps a bit.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kun.leeing |
Posted: Tue Feb 17, 2009 6:01 pm Post subject: |
|
|
 Disciple
Joined: 27 Sep 2008 Posts: 171
|
Thanks a lot.  |
|
Back to top |
|
 |
|