[jboss-user] [Messaging, JMS & JBossMQ] - Re: maxMessages

Renen do-not-reply at jboss.com
Wed Oct 24 05:39:27 EDT 2007


Hi Adrian, thanks for taking the time to reply. I have been chasing ill defined deadlines and wanted to make sure that I answered coherently rather than just shooting my mouth off.

I have re-run my experiments.

> I'd ignore MaxMessages (leave it a 1). 

If you don't set this message, the messages are delivered as they are received. Here is an exert from my logging:


  | 11:13:55,843 INFO  [STDOUT] I will send 2 message which will each execute for ten seconds.
  | 11:13:55,890 INFO  [STDOUT] Done generating messages.
  | 11:13:55,968 INFO  [STDOUT] A MDB has been CONSTRUCTED
  | 11:13:55,968 INFO  [STDOUT] A MDB has been CONSTRUCTED
  | 11:13:56,000 INFO  [STDOUT] 2: starting
  | 11:13:56,000 INFO  [STDOUT] 1: starting
  | 11:14:06,000 INFO  [STDOUT] 1: ending [75778423]
  | 11:14:06,000 INFO  [STDOUT] 2: ending [89124368]
  | 

If you set it to one, the messages are delivered one by one:


  | 11:16:25,140 INFO  [STDOUT] I will send 2 message which will each execute for ten seconds.
  | 11:16:25,187 INFO  [STDOUT] Done generating messages.
  | 11:16:25,250 INFO  [STDOUT] A MDB has been CONSTRUCTED
  | 11:16:25,265 INFO  [STDOUT] 1: starting
  | 11:16:35,265 INFO  [STDOUT] 1: ending [119664541]
  | 11:16:35,281 INFO  [STDOUT] 2: starting
  | 11:16:45,281 INFO  [STDOUT] 2: ending [123000458]
  | 

> i.e. one message arrives but it will sit there and not be delivered 
> until MaxMessages have arrived.

So, I set MaxMessages to 3. Clearly the two messages are delivered without any greater delay than in the preceding two scenarios:


  | 11:22:41,093 INFO  [STDOUT] I will send 2 message which will each execute for ten seconds.
  | 11:22:41,140 INFO  [STDOUT] Done generating messages.
  | 11:22:41,203 INFO  [STDOUT] A MDB has been CONSTRUCTED
  | 11:22:41,234 INFO  [STDOUT] A MDB has been CONSTRUCTED
  | 11:22:41,234 INFO  [STDOUT] 1: starting
  | 11:22:41,234 INFO  [STDOUT] 2: starting
  | 11:22:51,234 INFO  [STDOUT] 1: ending [84453291]
  | 11:22:51,234 INFO  [STDOUT] 2: ending [83080051]
  | 

Which is a huge pity: this control would have allowed me to throttle throughput (which is what I am really trying to do). From what you've said, relying on this behaviour is probably imprudent!

Should I report a bug? Or is my code wrong (its included below)? Otherwise, how should I throttle throughput?

Thank you!

Renen.

Note: I have either eliminated the entire propertyName = "MaxMessages", propertyValue="3" line, or changed the propertyValue setting depending on the scenario (above).


  | @MessageDriven(
  | 		mappedName = "jms/TestThroughputConsumer", activationConfig = {
  | 			@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/TestThroughput"),
  | 			@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
  | 			@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
  | 			
  | 			@ActivationConfigProperty(propertyName = "MaxMessages", propertyValue="3")
  | 		}
  | 	)
  | public class TestThroughputConsumer implements MessageListener {
  | 
  | 	public void onMessage(Message message) {
  | 		int id = getIntFromMessage(message);
  | 		System.out.println(id + ": starting");
  | 
  | 		Date end = new Date( (new Date()).getTime() + 10000 );
  | 		long i = 0;
  | 		while ( (new Date()).before(end) ) {
  | 			i = i+1;
  | 		}
  | 		System.out.println(id + ": ending [" + i + "]");
  | 	}
  | 	
  | 	@PostConstruct
  | 	public void postConstruct() {
  | 		System.out.println("A MDB has been CONSTRUCTED");
  | 	}
  | 	
  | 	@PreDestroy
  | 	public void preDestroy() {
  | 		System.out.println("MDB about to be DESTROYED");
  | 	}
  | 	
  | 	private int getIntFromMessage(Message message) {
  | 		int retval = 0;
  | 		try {
  | 			TestThroughput t = (TestThroughput)((ObjectMessage)message).getObject();
  | 			retval = t.getID();
  | 		} catch (JMSException e) {
  | 			Log.logError(0, "Error extracting message: " + e.getMessage(), this.getClass().getName());
  | 		}
  | 		return retval;
  | 	}
  | 	
  | 
  | }
  | 



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098196#4098196

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098196



More information about the jboss-user mailing list