Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
joram
joram
Commits
bd9a86f5
Commit
bd9a86f5
authored
Jun 16, 2010
by
Guillaume Surrel
Browse files
Adapt sample to new extended destinations.
parent
9a093062
Changes
4
Hide whitespace changes
Inline
Side-by-side
joram/samples/src/joram/collector/CollectorAdmin.java
View file @
bd9a86f5
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2008 - 200
9
ScalAgent Distributed Technologies
* Copyright (C) 2008 - 20
1
0 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/samples/src/joram/collector/Consumer.java
View file @
bd9a86f5
/*
* 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/samples/src/joram/collector/MsgListener.java
View file @
bd9a86f5
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2008 - 200
9
ScalAgent Distributed Technologies
* Copyright (C) 2008 - 20
1
0 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/samples/src/joram/collector/Producer.java
View file @
bd9a86f5
/*
* 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.
expiration
Message
"
,
"0"
);
msg
.
setStringProperty
(
"
collector.
persistent
Message
"
,
"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);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment