|  | 
 
  
    | RSS Feed - WebSphere MQ Support | RSS Feed - Message Broker Support |  
 
  
	|    |  |  
  
	| Java Thread Not receiveing Publish after second thread runs | « View previous topic :: View next topic » |  
  	| 
		
		
		  | Author | Message |  
		  | russell | 
			  
				|  Posted: Tue Aug 29, 2006 5:57 am    Post subject: Java Thread Not receiveing Publish after second thread runs |   |  |  
		  |  Newbie
 
 
 Joined: 24 Jun 2001Posts: 8
 
 
 | 
			  
				| has any one a solution to this problem. 
 I have a java program, which has multiple threads, 2 of which are Subscribers (different topics) registered as non-durable. Neither threads have any statics.
 
 Messages on Topic1 are published, and the thread1 processes them
 at some time latter Messages are published on Topic2 and Thread2 processes them, but thread1 stops processing its messages (that is it does not get a reply from the QM .
 
 I use
 msg = (TextMessage) subscriber.receive(timeout);
 // 10 sec
 
 My thread gets the return from the timeout, but not any message even though there are many messages on the queue.
 
 This happens with both a direct bind to the QM and a client connection.
 
 Any suggestion welcome.
 |  |  
		  | Back to top |  |  
		  |  |  
		  | fjb_saper | 
			  
				|  Posted: Tue Aug 29, 2006 6:31 pm    Post subject: |   |  |  
		  |  Grand High Poobah
 
 
 Joined: 18 Nov 2003Posts: 20767
 Location: LI,NY
 
 | 
			  
				| You seem to be sharing connection between the threads. This means you single thread the queue retrieval process. Have each thread create its own connection handle. 
 Enjoy
  _________________
 MQ & Broker admin
 |  |  
		  | Back to top |  |  
		  |  |  
		  | russell | 
			  
				|  Posted: Tue Aug 29, 2006 7:15 pm    Post subject: Second Thread blocking first |   |  |  
		  |  Newbie
 
 
 Joined: 24 Jun 2001Posts: 8
 
 
 | 
			  
				| Thanks Mate 
 That is what I thought, but I can't see where I am using the same connection.
 Unless I have stuffed up one of the parameters
 
 I do (striping out the try and debug lines) within each thread instance
 
 // these are thread contact admin - no statics
 
 TopicConnection connection;
 TopicSession session;
 TopicSubscriber subscriber;
 Topic myTopic;
 TextMessage msg;
 
 MQTopicConnectionFactory fact = new MQTopicConnectionFactory();
 fact.setTransportType(JMSC.MQJMS_TP_BINDINGS_MQ);
 fact.setQueueManager(queueManagerName);
 fact.setBrokerControlQueue("SYSTEM.BROKER.CONTROL.QUEUE");
 fact.setBrokerPubQueue("SYSTEM.BROKER.DEFAULT.STREAM");
 connection = fact.createTopicConnection();
 // Start connection
 connection.start();
 // Session TopicSession
 session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
 // Create a topic dynamically
 myTopic = session.createTopic(topic);
 subscriber = session.createSubscriber(myTopic);
 
 THEN JUST A LOOP CALLING
 msg = (TextMessage) subscriber.receive(timeout);
 
 Each of the Thread has it's own instances of all the above variables.
 Both threads do not die. None of the Catches are fired.
 And I get the return from receive with timeout.
 
 I expect createTopicSession to create a separate session.
 
 I did play with making the MQTopicConnectionFactory a singleton, but still the same effect.
 
 Any other sugestions welcome
 |  |  
		  | Back to top |  |  
		  |  |  
		  | russell | 
			  
				|  Posted: Tue Aug 29, 2006 11:06 pm    Post subject: |   |  |  
		  |  Newbie
 
 
 Joined: 24 Jun 2001Posts: 8
 
 
 | 
			  
				| Dont bother any more. 
 My own stupid error, I missed a NULL exception due to a bad catch.
 It just looked like a MQ problem, I will spend the rest of the day with a big "L" on my forhead.
 
 Thanks for the assist, if I wasn't looking for lost connections I would not have found it.
 |  |  
		  | Back to top |  |  
		  |  |  
		  |  |  |  
  
	|    |  | Page 1 of 1 |  
 
 
  
  	| 
		
		  | 
 
 | 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
 
 |  |  |  |