Commit eeb4fc14 authored by Guillaume Surrel's avatar Guillaume Surrel

JMSXDeliveryCount is now increased on DMQ delivery.

parent 44c96773
......@@ -113,13 +113,13 @@ public class TestDmq1 extends TestCase {
msg1=(TextMessage) consumert.receive(500);
assertEquals(null,msg1);
msg1=(TextMessage) consumerdq.receive();
msg1 = (TextMessage) consumerdq.receive();
assertEquals("message_q",msg1.getText());
assertEquals(2,msg1.getIntProperty("JMSXDeliveryCount"));
assertEquals(3, msg1.getIntProperty("JMSXDeliveryCount"));
msg1=(TextMessage) consumerdq1.receive();
msg1 = (TextMessage) consumerdq1.receive();
assertEquals("message_t",msg1.getText());
assertEquals(2,msg1.getIntProperty("JMSXDeliveryCount"));
assertEquals(3, msg1.getIntProperty("JMSXDeliveryCount"));
cnxq.close();
cnxdq.close();
......
......@@ -95,7 +95,7 @@ public class TestDmq2 extends TestCase {
msg1=(TextMessage) consumerdq.receive();
//test messages
assertEquals("message_1",msg1.getText());
assertEquals(2,msg1.getIntProperty("JMSXDeliveryCount"));
assertEquals(3, msg1.getIntProperty("JMSXDeliveryCount"));
cnx.close();
} catch (Throwable exc) {
......@@ -117,8 +117,7 @@ public class TestDmq2 extends TestCase {
org.objectweb.joram.client.jms.admin.AdminModule.connect("localhost", 2560,
"root", "root", 60);
// create a Queue
org.objectweb.joram.client.jms.Queue queue =
(org.objectweb.joram.client.jms.Queue) org.objectweb.joram.client.jms.Queue.create("queue");
org.objectweb.joram.client.jms.Queue queue = org.objectweb.joram.client.jms.Queue.create("queue");
// set permissions
queue.setFreeReading();
queue.setFreeWriting();
......
......@@ -34,114 +34,103 @@ import javax.naming.InitialContext;
import joram.framework.TestCase;
import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.client.jms.admin.DeadMQueue;
/**
* Test : set a default dmq and set a threshold for queue
*
*/
public class TestDmq3 extends TestCase {
public static void main(String[] args) {
new TestDmq3().run();
}
public void run() {
try {
System.out.println("server start");
startAgentServer((short)0);
admin();
System.out.println("admin config ok");
Context ictx = new InitialContext();
Queue queue = (Queue) ictx.lookup("queue");
DeadMQueue dmq =(DeadMQueue) ictx.lookup("dmq");
ConnectionFactory cf = (ConnectionFactory) ictx.lookup("cf");
ictx.close();
Connection cnx = cf.createConnection();
Session sessionp = cnx.createSession(false,
Session.AUTO_ACKNOWLEDGE);
Session sessionc = cnx.createSession(false,
Session.AUTO_ACKNOWLEDGE);
Session sessionc1 = cnx.createSession(true,
Session.AUTO_ACKNOWLEDGE);
cnx.start();
// create a producer and a consumer
MessageProducer producer = sessionp.createProducer(queue);
MessageConsumer consumerdq = sessionc.createConsumer(dmq);
MessageConsumer consumerq = sessionc1.createConsumer(queue);
// create a text message send to the queue by the pruducer
TextMessage msg = sessionp.createTextMessage();
msg= sessionp.createTextMessage("message_1");
producer.send(msg);
// the consumer receive the message from the dq
TextMessage msg1=(TextMessage) consumerq.receive();
sessionc1.rollback();
msg1=(TextMessage) consumerq.receive();
sessionc1.rollback();
msg1=(TextMessage) consumerq.receive(2000);
assertEquals(null,msg1);
msg1=(TextMessage) consumerdq.receive();
//test messages
assertEquals("message_1",msg1.getText());
assertEquals(2,msg1.getIntProperty("JMSXDeliveryCount"));
cnx.close();
} catch (Throwable exc) {
exc.printStackTrace();
error(exc);
} finally {
System.out.println("Server stop ");
stopAgentServer((short)0);
endTest();
}
}
/**
* Admin : Create queue and a user anonymous
* use jndi
*/
public void admin() throws Exception {
// conexion
org.objectweb.joram.client.jms.admin.AdminModule.connect("localhost", 2560,
"root", "root", 60);
// create a Queue
org.objectweb.joram.client.jms.Queue queue =
(org.objectweb.joram.client.jms.Queue) org.objectweb.joram.client.jms.Queue.create("queue");
// set permissions
queue.setFreeReading();
queue.setFreeWriting();
DeadMQueue dmq = (DeadMQueue) DeadMQueue.create(0);
dmq.setFreeReading();
dmq.setFreeWriting();
org.objectweb.joram.client.jms.admin.AdminModule.setDefaultDMQ(0,dmq);
queue.setThreshold(2);
// create a user
org.objectweb.joram.client.jms.admin.User user =
org.objectweb.joram.client.jms.admin.User.create("anonymous", "anonymous");
javax.jms.ConnectionFactory cf =
org.objectweb.joram.client.jms.tcp.TcpConnectionFactory.create("localhost", 2560);
javax.naming.Context jndiCtx = new javax.naming.InitialContext();
jndiCtx.bind("cf", cf);
jndiCtx.bind("queue", queue);
jndiCtx.bind("dmq", dmq);
jndiCtx.close();
org.objectweb.joram.client.jms.admin.AdminModule.disconnect();
public static void main(String[] args) {
new TestDmq3().run();
}
public void run() {
try {
System.out.println("server start");
startAgentServer((short) 0);
admin();
System.out.println("admin config ok");
Context ictx = new InitialContext();
Queue queue = (Queue) ictx.lookup("queue");
DeadMQueue dmq = (DeadMQueue) ictx.lookup("dmq");
ConnectionFactory cf = (ConnectionFactory) ictx.lookup("cf");
ictx.close();
Connection cnx = cf.createConnection();
Session sessionp = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sessionc = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session sessionc1 = cnx.createSession(true, Session.AUTO_ACKNOWLEDGE);
cnx.start();
// create a producer and a consumer
MessageProducer producer = sessionp.createProducer(queue);
MessageConsumer consumerdq = sessionc.createConsumer(dmq);
MessageConsumer consumerq = sessionc1.createConsumer(queue);
// create a text message send to the queue by the pruducer
TextMessage msg = sessionp.createTextMessage();
msg = sessionp.createTextMessage("message_1");
producer.send(msg);
// the consumer receive the message from the dq
TextMessage msg1 = (TextMessage) consumerq.receive();
sessionc1.rollback();
msg1 = (TextMessage) consumerq.receive();
sessionc1.rollback();
msg1 = (TextMessage) consumerq.receive(2000);
assertEquals(null, msg1);
msg1 = (TextMessage) consumerdq.receive();
//test messages
assertEquals("message_1", msg1.getText());
assertEquals(3, msg1.getIntProperty("JMSXDeliveryCount"));
cnx.close();
} catch (Throwable exc) {
exc.printStackTrace();
error(exc);
} finally {
System.out.println("Server stop ");
stopAgentServer((short) 0);
endTest();
}
}
/**
* Admin : Create queue and a user anonymous use jndi
*/
public void admin() throws Exception {
// conexion
AdminModule.connect("localhost", 2560, "root", "root", 60);
// create a Queue
org.objectweb.joram.client.jms.Queue queue = org.objectweb.joram.client.jms.Queue.create("queue");
// set permissions
queue.setFreeReading();
queue.setFreeWriting();
DeadMQueue dmq = (DeadMQueue) DeadMQueue.create(0);
dmq.setFreeReading();
dmq.setFreeWriting();
AdminModule.setDefaultDMQ(0, dmq);
queue.setThreshold(2);
// create a user
org.objectweb.joram.client.jms.admin.User.create("anonymous", "anonymous");
javax.jms.ConnectionFactory cf = org.objectweb.joram.client.jms.tcp.TcpConnectionFactory.create(
"localhost", 2560);
javax.naming.Context jndiCtx = new javax.naming.InitialContext();
jndiCtx.bind("cf", cf);
jndiCtx.bind("queue", queue);
jndiCtx.bind("dmq", dmq);
jndiCtx.close();
AdminModule.disconnect();
}
}
......@@ -95,7 +95,7 @@ public class TestDmq4 extends TestCase {
msg1=(TextMessage) consumerdq.receive();
//test messages
assertEquals("message_1",msg1.getText());
assertEquals(2,msg1.getIntProperty("JMSXDeliveryCount"));
assertEquals(3, msg1.getIntProperty("JMSXDeliveryCount"));
cnx.close();
} catch (Throwable exc) {
......
......@@ -95,7 +95,7 @@ public class TestDmq5 extends TestCase {
msg1=(TextMessage) consumerdq.receive();
//test messages
assertEquals("message_1",msg1.getText());
assertEquals(2,msg1.getIntProperty("JMSXDeliveryCount"));
assertEquals(3, msg1.getIntProperty("JMSXDeliveryCount"));
cnx.close();
} catch (Throwable exc) {
......
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