[jboss-user] [JBoss Messaging] - Re: Messaging Timeout thread pool limits configuration
amalcaraz
do-not-reply at jboss.com
Mon Nov 26 10:15:19 EST 2007
Sorry,
I have forgotten the unit test:
public class StressDeadLock {
| static final int MAX_MESSAGES = 4* 1000;
| static final int MAX_ROLLBACK_MESSAGES = 5;
| static final int DELAY_TIME = 60000;
| static final String HOST_NAME = "nostromo";
| static final String QUEUE_NAME = "/queue/QueueWithOwnRedeliveryDelay";
|
| @Test
| public void stressTest1() {
| InitialContext ctx = null;
| ConnectionFactory connectionFactory = null;
| Queue destination = null;
| Connection sdnConnection = null;
| Connection rcvConnection = null;
| Session sndSession = null;
| Session rcvSession = null;
| MessageProducer producer = null;
| MessageConsumer consumer = null;
|
| String body = "Message schedule test";
|
| try {
| Properties props = new Properties();
| props.put(Context.INITIAL_CONTEXT_FACTORY,
| "org.jnp.interfaces.NamingContextFactory");
| props.put(Context.PROVIDER_URL, HOST_NAME + ":1099");
| props.put("java.naming.factory.url.pkgs",
| "org.jboss.naming:org.jnp.interfaces");
| ctx = new InitialContext(props);
| connectionFactory = (ConnectionFactory) ctx
| .lookup("/ConnectionFactory");
| destination = (Queue) ctx.lookup(QUEUE_NAME);
|
| sdnConnection = connectionFactory.createConnection();
| sndSession = sdnConnection.createSession(false,
| Session.AUTO_ACKNOWLEDGE);
|
| rcvConnection = connectionFactory.createConnection();
| rcvConnection.start();
| rcvSession = rcvConnection.createSession(true,
| Session.SESSION_TRANSACTED);
|
| consumer = rcvSession.createConsumer(destination);
| producer = sndSession.createProducer(destination);
|
| long deliveryTime = System.currentTimeMillis() + DELAY_TIME;
| int msgCounter = 0;
| int rollbackCounter = 0;
|
| while (msgCounter < MAX_MESSAGES) {
| TextMessage msg = sndSession.createTextMessage(body);
| msg.setLongProperty(
| JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME,
| deliveryTime);
| producer.send(msg);
|
| msgCounter++;
| System.out.println("Sending " + msgCounter + "...");
| }
|
| while (consumer.receive(DELAY_TIME) != null) {
| if (rollbackCounter < MAX_ROLLBACK_MESSAGES) {
| rcvSession.rollback();
|
| rollbackCounter++;
| } else {
| rcvSession.commit();
| }
|
| msgCounter--;
| System.out.println("Pending for receive " + msgCounter + "...");
| }
|
| assertFalse(msgCounter > (-1 * rollbackCounter));
| } catch (Exception e) {
| fail(e.getMessage());
| } finally {
| if (consumer != null) {
| try {
| consumer.close();
| } catch (Exception e) {
| }
| }
|
| if (producer != null) {
| try {
| producer.close();
| } catch (Exception e) {
| }
| }
|
| if (sndSession != null) {
| try {
| sndSession.close();
| } catch (Exception e) {
| }
| }
| if (rcvSession != null) {
| try {
| rcvSession.close();
| } catch (Exception e) {
| }
| }
|
| if (rcvConnection != null) {
| try {
| rcvConnection.close();
| } catch (Exception e) {
| }
| }
|
| if (sdnConnection != null) {
| try {
| sdnConnection.close();
| } catch (Exception e) {
| }
| }
|
| if (ctx != null) {
| try {
| ctx.close();
| } catch (Exception e) {
| }
| }
| }
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107764#4107764
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107764
More information about the jboss-user
mailing list