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

Adapt sample to new extended destinations.

parent 9a093062
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2008 - 2009 ScalAgent Distributed Technologies
* Copyright (C) 2008 - 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,20 +25,20 @@ package collector;
import java.util.Properties;
import org.objectweb.joram.client.jms.Queue;
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.messages.Message;
/**
* Administers an agent server for the classic samples.
* Administers an agent server for the URL acquisition samples.
*/
public class CollectorAdmin {
public static void main(String[] args) throws Exception {
String url = "http://svn.forge.objectweb.org/cgi-bin/viewcvs.cgi/*checkout*/joram/trunk/joram/history";
// The collected URL
String url = "http://www.gnu.org/licenses/lgpl-2.1.txt";
System.out.println();
System.out.println("Collector administration...");
......@@ -47,13 +47,13 @@ public class CollectorAdmin {
Properties prop = new Properties();
prop.setProperty("expiration", "0");
prop.setProperty("persistent", "true");
prop.setProperty("period", "300000");
prop.setProperty("acquisition.period", "10000");
prop.setProperty("acquisition.className", "com.scalagent.joram.mom.dest.collector.URLAcquisition");
prop.setProperty("collector.url", url);
prop.setProperty("collector.type", "" + Message.BYTES);
prop.setProperty("collector.className", "com.scalagent.joram.mom.dest.collector.URLCollector");
Queue queue = Queue.create(0, "queue", Queue.COLLECTOR_QUEUE, prop);
// Topic topic = Topic.create(0, "topic", Topic.COLLECTOR_TOPIC, prop);
Queue queue = Queue.create(0, "queue", Queue.ACQUISITION_QUEUE, prop);
// Topic topic = Topic.create(0, "topic", Topic.ACQUISITION_TOPIC, prop);
User.create("anonymous", "anonymous");
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2008 ScalAgent Distributed Technologies
* Copyright (C) 2008 - 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 collector;
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.
......@@ -33,7 +38,7 @@ public class Consumer {
public static void main(String[] args) throws Exception {
System.out.println();
System.out.println("Listens to the collector queue and to the collector topic...");
System.out.println("Listens to the collector queue...");
ictx = new InitialContext();
Queue queue = (Queue) ictx.lookup("queue");
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2008 - 2009 ScalAgent Distributed Technologies
* Copyright (C) 2008 - 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,6 +22,8 @@
*/
package collector;
import java.util.Enumeration;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
......@@ -45,15 +47,17 @@ public class MsgListener implements MessageListener {
Destination destination = msg.getJMSDestination();
Destination replyTo = msg.getJMSReplyTo();
System.out.println(ident + "from=" + destination + ",replyTo=" + replyTo);
System.out.println();
System.out.println("URL collected:");
System.out.println(ident + ": from=" + destination + ",replyTo=" + replyTo);
Enumeration e = msg.getPropertyNames();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
String value = msg.getStringProperty(key);
System.out.println(ident + ": " + key + " = " + value);
}
// Enumeration e = msg.getPropertyNames();
// while (e.hasMoreElements()) {
// String key = (String) e.nextElement();
// String value = msg.getStringProperty(key);
// System.out.println(ident + ": " + key + " = " + value);
// }
//
// if (msg instanceof TextMessage) {
// System.out.println(((TextMessage) msg).getText());
// } else if (msg instanceof BytesMessage) {
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2008 ScalAgent Distributed Technologies
* Copyright (C) 2008 - 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,18 +22,25 @@
*/
package collector;
import javax.jms.*;
import javax.naming.*;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.naming.Context;
import javax.naming.InitialContext;
/**
* update properties on the collector queue and on the collector topic.
* Updates properties on the URL acquisition queue to change the acquisition
* period and URL.
*/
public class Producer {
static Context ictx = null;
public static void main(String[] args) throws Exception {
System.out.println();
System.out.println("update properties on the collector queue and on the collector topic...");
System.out.println("update properties on the collector queue...");
ictx = new InitialContext();
Queue queue = (Queue) ictx.lookup("queue");
......@@ -46,10 +53,10 @@ public class Producer {
MessageProducer producer = sess.createProducer(null);
Message msg = sess.createMessage();
msg.setStringProperty("collector.expirationMessage", "0");
msg.setStringProperty("collector.persistentMessage", "true");
msg.setStringProperty("collector.period", "30000");
msg.setStringProperty("collector.url", "http://svn.forge.objectweb.org/cgi-bin/viewcvs.cgi/*checkout*/joram/trunk/joram/history");
msg.setStringProperty("expiration", "0");
msg.setStringProperty("persistent", "true");
msg.setStringProperty("acquisition.period", "30000");
msg.setStringProperty("collector.url", "http://www.gnu.org/licenses/lgpl-3.0.txt");
msg.setStringProperty("collector.type", "5");
producer.send(queue, msg);
// producer.send(topic, msg);
......
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