Commit d3be5f13 authored by Nicolas Tachker's avatar Nicolas Tachker

JORAM-260: Add feature: re-delivery delay - this parameter allows you to...

JORAM-260: Add feature: re-delivery delay - this parameter allows you to control the delay time for that redelivery.
parent a10771e0
......@@ -6794,6 +6794,7 @@
<antcall target="jms2.test12"/>
<antcall target="jms2.sharedTest1"/>
<antcall target="jms2.sharedTest2"/>
<antcall target="jms2.redeliveryDelay"/>
</target>
<target name="jms2.test1" depends="init.a3props,compile"
......@@ -6977,6 +6978,94 @@
<param name="args" value=""/>
</antcall>
</target>
<target name="jms2.redeliveryDelay"
description=" --> launch all jms2.redeliveryDelay tests">
<antcall target="jms2.redeliveryDelay_T_T"/>
<antcall target="jms2.redeliveryDelay_T_C"/>
<antcall target="jms2.redeliveryDelay_T_A"/>
<antcall target="jms2.redeliveryDelay_Q_T"/>
<antcall target="jms2.redeliveryDelay_Q_C"/>
<antcall target="jms2.redeliveryDelay_Q_A"/>
</target>
<target name="jms2.redeliveryDelay_T_T" depends="init.a3props,compile"
description=" --> Test re-delivery delay topic transacted">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
<param name="testid" value="jms2.redeliveryDelay_T"/>
<param name="className" value="joram.jms2.RedeliveryDelay_T"/>
<param name="jndiconf" value="jms2/jndi.properties"/>
<param name="a3conf" value="jms2/a3servers1.xml"/>
<param name="jvmargs" value=""/>
<param name="args" value="0"/><!-- 0 = transacted -->
</antcall>
</target>
<target name="jms2.redeliveryDelay_Q_T" depends="init.a3props,compile"
description=" --> Test re-delivery delay queue transacted">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
<param name="testid" value="jms2.redeliveryDelay_Q"/>
<param name="className" value="joram.jms2.RedeliveryDelay_Q"/>
<param name="jndiconf" value="jms2/jndi.properties"/>
<param name="a3conf" value="jms2/a3servers1.xml"/>
<param name="jvmargs" value=""/>
<param name="args" value="0"/><!-- 0 = transacted -->
</antcall>
</target>
<target name="jms2.redeliveryDelay_T_A" depends="init.a3props,compile"
description=" --> Test re-delivery delay topic transacted">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
<param name="testid" value="jms2.redeliveryDelay_T"/>
<param name="className" value="joram.jms2.RedeliveryDelay_T"/>
<param name="jndiconf" value="jms2/jndi.properties"/>
<param name="a3conf" value="jms2/a3servers1.xml"/>
<param name="jvmargs" value=""/>
<param name="args" value="1"/><!-- 1 = autoACK -->
</antcall>
</target>
<target name="jms2.redeliveryDelay_Q_A" depends="init.a3props,compile"
description=" --> Test re-delivery delay queue transacted">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
<param name="testid" value="jms2.redeliveryDelay_Q"/>
<param name="className" value="joram.jms2.RedeliveryDelay_Q"/>
<param name="jndiconf" value="jms2/jndi.properties"/>
<param name="a3conf" value="jms2/a3servers1.xml"/>
<param name="jvmargs" value=""/>
<param name="args" value="1"/><!-- 1 = autoACK -->
</antcall>
</target>
<target name="jms2.redeliveryDelay_T_C" depends="init.a3props,compile"
description=" --> Test re-delivery delay topic clientACK">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
<param name="testid" value="jms2.redeliveryDelay_T"/>
<param name="className" value="joram.jms2.RedeliveryDelay_T"/>
<param name="jndiconf" value="jms2/jndi.properties"/>
<param name="a3conf" value="jms2/a3servers.xml"/>
<param name="jvmargs" value=""/>
<param name="args" value="2"/><!-- 2 = clientACK -->
</antcall>
</target>
<target name="jms2.redeliveryDelay_Q_C" depends="init.a3props,compile"
description=" --> Test re-delivery delay queue clientACK">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
<param name="testid" value="jms2.redeliveryDelay_Q"/>
<param name="className" value="joram.jms2.RedeliveryDelay_Q"/>
<param name="jndiconf" value="jms2/jndi.properties"/>
<param name="a3conf" value="jms2/a3servers.xml"/>
<param name="jvmargs" value=""/>
<param name="args" value="2"/><!-- 2 = clientACK -->
</antcall>
</target>
<target name="medical.test1" depends="compile"
description=" --> Medical use-case">
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2016 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s):
* Contributor(s):
*/
package joram.jms2;
import java.util.Properties;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.JMSConsumer;
import javax.jms.JMSContext;
import javax.jms.JMSException;
import javax.jms.JMSProducer;
import javax.jms.Message;
import javax.jms.TextMessage;
import org.objectweb.joram.client.jms.Queue;
import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.client.jms.admin.User;
import org.objectweb.joram.client.jms.tcp.TcpConnectionFactory;
import org.objectweb.joram.shared.admin.AdminCommandConstant;
import fr.dyade.aaa.agent.AgentServer;
import framework.TestCase;
/**
* Test : The message received by the consumer rollback, recover or throw an exception.
* The delivery delay is set on server. The message must re-delivered
* after the delivery delay.
*/
public class RedeliveryDelay_Q extends TestCase implements javax.jms.MessageListener {
public static void main(String[] args) {
new RedeliveryDelay_Q().run(Integer.parseInt(args[0]));
}
JMSContext context;
JMSConsumer consumer;
public void run(int sessionMode) {
try {
startAgentServer((short) 0);
Thread.sleep(1000);
ConnectionFactory cf = TcpConnectionFactory.create("localhost", 2560);
AdminModule.connect(cf, "root", "root");
User.create("anonymous", "anonymous", 0);
Queue dest;
if (AgentServer.getProperty(AdminCommandConstant.RE_DELIVERY_DELAY) != null) {
dest = Queue.create("queue");
}
else {
Properties prop = new Properties();
prop.setProperty(AdminCommandConstant.RE_DELIVERY_DELAY, "3");
prop.setProperty("name", "queue");
dest = Queue.create(0, prop);
}
dest.setFreeReading();
dest.setFreeWriting();
AdminModule.disconnect();
switch (sessionMode) {
case JMSContext.SESSION_TRANSACTED:
context = cf.createContext(JMSContext.SESSION_TRANSACTED);
break;
case JMSContext.CLIENT_ACKNOWLEDGE:
context = cf.createContext(JMSContext.CLIENT_ACKNOWLEDGE);
break;
default:
context = cf.createContext(JMSContext.AUTO_ACKNOWLEDGE);
break;
}
consumer = context.createConsumer(dest);
consumer.setMessageListener(this);
context.start();
JMSContext prodCtx = cf.createContext();
JMSProducer producer = prodCtx.createProducer();
producer.setDeliveryMode(DeliveryMode.PERSISTENT);
TextMessage msg = prodCtx.createTextMessage("test redeliveryTime");
producer.send(dest, msg);
// Wait to receive the message.
Thread.sleep(6000);
assertTrue("The rollback or recover message not received after the redelivery delay", time < 6000);
context.close();
prodCtx.close();
} catch (Throwable exc) {
exc.printStackTrace();
error(exc);
} finally {
stopAgentServer((short) 0);
endTest();
}
}
private boolean first = true;
private long time = 0;
public void onMessage(Message message) {
try {
System.out.println(System.currentTimeMillis() + ": message received deliveryTime = " + message.getJMSDeliveryTime());
System.out.println("JMSRedelivered = " + message.getJMSRedelivered());
} catch (JMSException e) {
e.printStackTrace();
}
time = System.currentTimeMillis() - time;
if (first) {
first = false;
switch (context.getSessionMode()) {
case JMSContext.SESSION_TRANSACTED:
System.out.println("rollback");
context.rollback();
break;
case JMSContext.CLIENT_ACKNOWLEDGE:
System.out.println("recover");
context.recover();
break;
default:
System.out.println("throw RuntimeException");
throw new RuntimeException("Test redeliveryTime");
}
}
}
}
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2016 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s):
* Contributor(s):
*/
package joram.jms2;
import java.util.Properties;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.JMSConsumer;
import javax.jms.JMSContext;
import javax.jms.JMSException;
import javax.jms.JMSProducer;
import javax.jms.Message;
import javax.jms.TextMessage;
import org.objectweb.joram.client.jms.Topic;
import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.client.jms.admin.User;
import org.objectweb.joram.client.jms.tcp.TcpConnectionFactory;
import org.objectweb.joram.shared.admin.AdminCommandConstant;
import org.objectweb.joram.shared.security.SimpleIdentity;
import fr.dyade.aaa.agent.AgentServer;
import framework.TestCase;
/**
* Test : The message received by the consumer rollback, recover or throw an exception.
* The delivery delay is set on server. The message must re-delivered
* after the delivery delay.
*/
public class RedeliveryDelay_T extends TestCase implements javax.jms.MessageListener {
public static void main(String[] args) {
new RedeliveryDelay_T().run(Integer.parseInt(args[0]));
}
JMSContext context;
public void run(int sessionMode) {
try {
startAgentServer((short) 0);
Thread.sleep(1000);
ConnectionFactory cf = TcpConnectionFactory.create("localhost", 2560);
AdminModule.connect(cf, "root", "root");
if (AgentServer.getProperty(AdminCommandConstant.RE_DELIVERY_DELAY) != null) {
User.create("anonymous", "anonymous", 0);
} else {
Properties prop = new Properties();
prop.setProperty(AdminCommandConstant.RE_DELIVERY_DELAY, "3");
User.create("anonymous", "anonymous", 0, SimpleIdentity.class.getName(), prop);
}
Topic dest = Topic.create("topic");
dest.setFreeReading();
dest.setFreeWriting();
AdminModule.disconnect();
switch (sessionMode) {
case JMSContext.SESSION_TRANSACTED:
context = cf.createContext(JMSContext.SESSION_TRANSACTED);
break;
case JMSContext.CLIENT_ACKNOWLEDGE:
context = cf.createContext(JMSContext.CLIENT_ACKNOWLEDGE);
break;
default:
context = cf.createContext(JMSContext.AUTO_ACKNOWLEDGE);
break;
}
JMSConsumer consumer = context.createConsumer(dest);
consumer.setMessageListener(this);
context.start();
JMSContext prodCtx = cf.createContext();
JMSProducer producer = prodCtx.createProducer();
producer.setDeliveryMode(DeliveryMode.PERSISTENT);
TextMessage msg = prodCtx.createTextMessage("test redeliveryTime");
producer.send(dest, msg);
// Wait to receive the message.
Thread.sleep(6000);
assertTrue("The rollback or recover message not received after the redelivery delay", time < 6000);
context.close();
prodCtx.close();
} catch (Throwable exc) {
exc.printStackTrace();
error(exc);
} finally {
stopAgentServer((short) 0);
endTest();
}
}
private boolean first = true;
private long time = 0;
public void onMessage(Message message) {
try {
System.out.println(System.currentTimeMillis() + ": message received deliveryTime = " + message.getJMSDeliveryTime());
System.out.println("JMSRedelivered = " + message.getJMSRedelivered());
} catch (JMSException e) {
e.printStackTrace();
}
time = System.currentTimeMillis() - time;
if (first) {
time = System.currentTimeMillis();
first = false;
switch (context.getSessionMode()) {
case JMSContext.SESSION_TRANSACTED:
System.out.println("rollback");
context.rollback();
break;
case JMSContext.CLIENT_ACKNOWLEDGE:
System.out.println("recover");
context.recover();
break;
default:
System.out.println("throw RuntimeException");
throw new RuntimeException("Test redeliveryTime");
}
}
}
}
<?xml version="1.0"?>
<config>
<property name="Transaction" value="fr.dyade.aaa.util.NullTransaction"/>
<property name="jms_joram_re_delivery_delay" value="5"/>
<server id="0" name="s0" hostname="localhost">
<service class="fr.dyade.aaa.agent.AdminProxy" args="7890"/>
<service class="org.objectweb.joram.mom.proxies.ConnectionManager" args="root root"/>
<service class="org.objectweb.joram.mom.proxies.tcp.TcpProxyService" args="2560"/>
<service class="fr.dyade.aaa.jndi2.server.JndiServer" args="16400"/>
</server>
</config>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment