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
c5b63be7
Commit
c5b63be7
authored
Jun 16, 2010
by
Guillaume Surrel
Browse files
Adapt sample to new extended destinations.
parent
bd9a86f5
Changes
4
Hide whitespace changes
Inline
Side-by-side
joram/samples/src/joram/mail/Consumer.java
View file @
c5b63be7
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2003 - 200
6
ScalAgent Distributed Technologies
* Copyright (C) 2003 - 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,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
(
"
m
ailQueue"
);
Queue
queue
=
(
Queue
)
ictx
.
lookup
(
"
receiveM
ailQueue"
);
ConnectionFactory
cf
=
(
ConnectionFactory
)
ictx
.
lookup
(
"cf"
);
ictx
.
close
();
...
...
joram/samples/src/joram/mail/MailAdmin.java
View file @
c5b63be7
/*
* 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
(
"
smt
p.properties"
));
Topic
topic
=
Topic
.
create
(
0
,
null
,
"com.scalagent.joram.mom.dest.mail.JavaMailTopic"
,
prop
);
prop
.
load
(
new
FileInputStream
(
"
po
p.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
(
"
m
ailQueue"
,
queue
);
jndiCtx
.
bind
(
"
m
ailTopic"
,
topic
);
jndiCtx
.
bind
(
"
receiveM
ailQueue"
,
queue
);
jndiCtx
.
bind
(
"
sendM
ailTopic"
,
topic
);
jndiCtx
.
close
();
AdminModule
.
disconnect
();
...
...
joram/samples/src/joram/mail/Producer.java
View file @
c5b63be7
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2003 - 200
6
ScalAgent Distributed Technologies
* Copyright (C) 2003 - 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,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
(
"
m
ailTopic"
);
Topic
topic
=
(
Topic
)
ictx
.
lookup
(
"
sendM
ailTopic"
);
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
);
}
...
...
joram/samples/src/joram/mail/pop.properties
View file @
c5b63be7
popServer
=
popP
eriod
=
5000
acquisition.p
eriod
=
5000
popUser
=
popPassword
=
expunge
=
true
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