ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » MQGET with wait and threading in Java (non-JMS)

Post new topic  Reply to topic
 MQGET with wait and threading in Java (non-JMS) « View previous topic :: View next topic » 
Author Message
gorilla
PostPosted: Wed Dec 07, 2005 3:47 am    Post subject: MQGET with wait and threading in Java (non-JMS) Reply with quote

Novice

Joined: 17 Nov 2005
Posts: 16

A while ago I wrote a program using the non-JMS Java interface. It was designed to read out a queue which was been loaded by a fast program (designed to demonstrate how fast you can do MQPUTs from Java) so the GET program was (a) reading a lot of messages and (b) reporting its times.

I originally wrote it with two separete GET threads - one for the data queue and the other for commands carried as MQ messages (a side effect of the "cut and paste" school of prgramming
Anyway, I had two Java threads, each one doing a get wait, but on different queues. Get wait is a blocking call, so both threads are on timed loops so they can react to external signals.

This produced an unexpected effect: the two threads interfered with each other. As far as I could make out they were running in series instead of in parallel. The command thread would wait out one cycle, during which the data thread did nothing, then the data thread would read messages for one cycle, then the command thread would wait one cycle again. Effective get rate was a few hundred messages per second.

This isn't much of a problem (it cost maybe 10 lines of code in total to bypass) but I'd like to understand better where it's coming from.

I got around it by removing the get wait - that is, the code does a get, reacts to the "no message in queue" exception, and uses Thread.sleep before checking again.
FWIW, the current version runs about as fast as an unthreaded version with just one get wait - I got over 10K messages per second on a laptop PC (small non-persistent messages of course) and something over 2000 per second with persistent messages.

Does anyone know what the "interference effect" is due to?
Back to top
View user's profile Send private message
wschutz
PostPosted: Wed Dec 07, 2005 4:12 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Were both threads using the same qmgr object, or did you create two qmgr objects, one for each thread. If its only one object, you can only have one operation at a time on that object.
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
gorilla
PostPosted: Wed Dec 07, 2005 7:50 am    Post subject: Reply with quote

Novice

Joined: 17 Nov 2005
Posts: 16

Thanks Wayne - right first time.

This is a bit embarrasing actually because I should have figured this out myself - I've had the same problem before
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » MQGET with wait and threading in Java (non-JMS)
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.