Commit c5b63be7 authored by Guillaume Surrel's avatar Guillaume Surrel
Browse files

Adapt sample to new extended destinations.

parent bd9a86f5
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2003 - 2006 ScalAgent Distributed Technologies
* Copyright (C) 2003 - 2010 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
......@@ -22,8 +22,13 @@
*/
package mail;
import javax.jms.*;
import javax.naming.*;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.naming.Context;
import javax.naming.InitialContext;
/**
* Consumes messages from the queue and from the topic.
......@@ -35,7 +40,7 @@ public class Consumer {
System.out.println("Trace1");
ictx = new InitialContext();
Queue queue = (Queue) ictx.lookup("mailQueue");
Queue queue = (Queue) ictx.lookup("receiveMailQueue");
ConnectionFactory cf = (ConnectionFactory) ictx.lookup("cf");
ictx.close();
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2006 ScalAgent Distributed Technologies
* Copyright (C) 2006 - 2010 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
......@@ -25,6 +25,7 @@ package mail;
import java.io.FileInputStream;
import java.util.Properties;
import org.objectweb.joram.client.jms.Destination;
import org.objectweb.joram.client.jms.Queue;
import org.objectweb.joram.client.jms.Topic;
import org.objectweb.joram.client.jms.admin.AdminModule;
......@@ -36,16 +37,18 @@ public class MailAdmin {
System.out.println("mail administration...");
AdminModule.connect("root", "root", 60);
// Create a topic forwarding its messages to the configured email address.
Properties prop = new Properties();
prop.load(new FileInputStream("pop.properties"));
Queue queue = Queue.create(0, null,
"com.scalagent.joram.mom.dest.mail.JavaMailQueue",prop);
prop.load(new FileInputStream("smtp.properties"));
prop.put("distribution.className", "com.scalagent.joram.mom.dest.mail.MailDistribution");
Topic topic = Topic.create(0, null, Destination.DISTRIBUTION_TOPIC, prop);
// Create a queue getting its messages from the configured email address.
prop = new Properties();
prop.load(new FileInputStream("smtp.properties"));
Topic topic = Topic.create(0,null,
"com.scalagent.joram.mom.dest.mail.JavaMailTopic",prop);
prop.load(new FileInputStream("pop.properties"));
prop.put("acquisition.className", "com.scalagent.joram.mom.dest.mail.MailAcquisition");
Queue queue = Queue.create(0, null, Destination.ACQUISITION_QUEUE, prop);
javax.jms.ConnectionFactory cf = TcpConnectionFactory.create("localhost", 16010);
......@@ -59,8 +62,8 @@ public class MailAdmin {
javax.naming.Context jndiCtx = new javax.naming.InitialContext();
jndiCtx.bind("cf", cf);
jndiCtx.bind("mailQueue", queue);
jndiCtx.bind("mailTopic", topic);
jndiCtx.bind("receiveMailQueue", queue);
jndiCtx.bind("sendMailTopic", topic);
jndiCtx.close();
AdminModule.disconnect();
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2003 - 2006 ScalAgent Distributed Technologies
* Copyright (C) 2003 - 2010 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
......@@ -22,8 +22,14 @@
*/
package mail;
import javax.jms.*;
import javax.naming.*;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;
import javax.naming.Context;
import javax.naming.InitialContext;
/**
* Produces messages on the queue and on the topic.
......@@ -33,7 +39,7 @@ public class Producer {
public static void main(String[] args) throws Exception {
ictx = new InitialContext();
Topic topic = (Topic) ictx.lookup("mailTopic");
Topic topic = (Topic) ictx.lookup("sendMailTopic");
ConnectionFactory cf = (ConnectionFactory) ictx.lookup("cf");
ictx.close();
......@@ -45,10 +51,7 @@ public class Producer {
for (int i=0; i<5; i++) {
TextMessage msg = sess.createTextMessage();
msg.setBooleanProperty("showProperties", true);
msg.setStringProperty("property1", "valeur#" + i);
msg.setIntProperty("property2", i);
msg.setBooleanProperty("showProperties", false);
msg.setText("Queue : Test number #" + i);
producer.send(msg);
}
......
popServer=
popPeriod=5000
acquisition.period=5000
popUser=
popPassword=
expunge=true
Supports Markdown
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