Author: arnaudsimon
Date: Wed Jan 16 06:45:42 2008
New Revision: 612473
URL: http://svn.apache.org/viewvc?rev=612473&view=rev
Log:
Changed for using JNDI destinations and log4J conf file
Added:
incubator/qpid/trunk/qpid/java/client/example/src/main/java/log4j.xml
(contents, props changed)
- copied, changed from r612384,
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/log4j.xml
incubator/qpid/trunk/qpid/java/client/example/src/main/java/sample.properties
Modified:
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/common/BaseExample.java
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Consumer.java
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Producer.java
incubator/qpid/trunk/qpid/java/client/example/src/main/java/runSample.sh
Copied: incubator/qpid/trunk/qpid/java/client/example/src/main/java/log4j.xml
(from r612384,
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/log4j.xml)
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/log4j.xml?p2=incubator/qpid/trunk/qpid/java/client/example/src/main/java/log4j.xml&p1=incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/log4j.xml&r1=612384&r2=612473&rev=612473&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/log4j.xml
(original)
+++ incubator/qpid/trunk/qpid/java/client/example/src/main/java/log4j.xml Wed
Jan 16 06:45:42 2008
@@ -22,7 +22,7 @@
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="FileAppender" class="org.apache.log4j.FileAppender">
- <param name="File" value="ams_messaging.log"/>
+ <param name="File" value="qpid_messaging.log"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
@@ -31,15 +31,19 @@
</appender>
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
-
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L)
- %m%n"/>
</layout>
</appender>
+ <logger name="org.apache">
+ <!-- Print only messages of level warn or above in the package
org.apache -->
+ <level value="warn"/>
+ </logger>
+
<root>
<priority value="info"/>
<appender-ref ref="STDOUT"/>
- <appender-ref ref="FileAppender"/>
+ <!-- <appender-ref ref="FileAppender"/> -->
</root>
</log4j:configuration>
Propchange:
incubator/qpid/trunk/qpid/java/client/example/src/main/java/log4j.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/qpid/trunk/qpid/java/client/example/src/main/java/log4j.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified:
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/common/BaseExample.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/common/BaseExample.java?rev=612473&r1=612472&r2=612473&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/common/BaseExample.java
(original)
+++
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/common/BaseExample.java
Wed Jan 16 06:45:42 2008
@@ -42,14 +42,14 @@
abstract public class BaseExample
{
/* The AMQP INITIAL_CONTEXT_FACTORY */
- private static final String INITIAL_CONTEXT_FACTORY_NAME =
+ private static final String INITIAL_CONTEXT_FACTORY_NAME=
"org.apache.qpid.jndi.PropertiesFileInitialContextFactory";
/* Default connection factory name. */
- private static final String DEFAULT_CONNECTION_FACTORY_NAME =
"ConnectionFactory";
+ private static final String
DEFAULT_CONNECTION_FACTORY_NAME="ConnectionFactory";
/* Default number of messages to process. */
- private static final int DEFAULT_NUMBER_MESSAGES = 1;
+ private static final int DEFAULT_NUMBER_MESSAGES=10;
/* JNDI provider URL. */
private String _providerURL;
@@ -64,10 +64,10 @@
protected ArgProcessor _argProcessor;
/* The supported properties */
- protected static Properties _options = new Properties();
+ protected static Properties _options=new Properties();
/* The properties default values */
- protected static Properties _defaults = new Properties();
+ protected static Properties _defaults=new Properties();
/* The broker communication objects */
private InitialContext _initialContext;
@@ -89,14 +89,14 @@
_options.put("-numMessages", "Number of messages to process");
_defaults.put("-numMessages", String.valueOf(DEFAULT_NUMBER_MESSAGES));
- _argProcessor = new ArgProcessor(Id, args, _options, _defaults);
+ _argProcessor=new ArgProcessor(Id, args, _options, _defaults);
_argProcessor.display();
//Set the initial context factory
- _providerURL = _argProcessor.getStringArgument("-providerURL");
+ _providerURL=_argProcessor.getStringArgument("-providerURL");
// Set the number of messages
- _numberMessages = _argProcessor.getIntegerArgument("-numMessages");
+ _numberMessages=_argProcessor.getIntegerArgument("-numMessages");
// Set the delivery mode
- _deliveryMode = _argProcessor.getStringArgument("-deliveryMode")
+ _deliveryMode=_argProcessor.getStringArgument("-deliveryMode")
.equals("persistent") ? DeliveryMode.PERSISTENT :
DeliveryMode.NON_PERSISTENT;
}
@@ -143,15 +143,18 @@
{
if (_initialContext == null)
{
- Hashtable<String, String> jndiEnvironment = new Hashtable<String,
String>();
- jndiEnvironment.put(Context.INITIAL_CONTEXT_FACTORY,
INITIAL_CONTEXT_FACTORY_NAME);
- jndiEnvironment.put("connectionfactory.ConnectionFactory",
-
"qpid:password=guest;username=guest;client_id=clientid;[EMAIL
PROTECTED]:127.0.0.1:5672");
+ Hashtable<String, String> jndiEnvironment=new Hashtable<String,
String>();
+ jndiEnvironment.put(Context.INITIAL_CONTEXT_FACTORY,
INITIAL_CONTEXT_FACTORY_NAME);
if (getProviderURL() != null)
{
jndiEnvironment.put(Context.PROVIDER_URL, getProviderURL());
}
- _initialContext = new InitialContext(jndiEnvironment);
+ else
+ {
+ jndiEnvironment.put("connectionfactory.ConnectionFactory",
+
"qpid:password=guest;username=guest;client_id=clientid;[EMAIL
PROTECTED]:127.0.0.1:5672");
+ }
+ _initialContext=new InitialContext(jndiEnvironment);
}
return _initialContext;
}
@@ -166,7 +169,7 @@
{
if (_connectionFactory == null)
{
- _connectionFactory = (ConnectionFactory)
getInitialContext().lookup(DEFAULT_CONNECTION_FACTORY_NAME);
+ _connectionFactory=(ConnectionFactory)
getInitialContext().lookup(DEFAULT_CONNECTION_FACTORY_NAME);
}
return _connectionFactory;
}
Modified:
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Consumer.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Consumer.java?rev=612473&r1=612472&r2=612473&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Consumer.java
(original)
+++
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Consumer.java
Wed Jan 16 06:45:42 2008
@@ -57,7 +57,7 @@
public static void main(String[] args)
{
_options.put("-queueName", "Queue name");
- _defaults.put("-queueName", "message_queue");
+ _defaults.put("-queueName", "direct_message_queue");
Consumer syncConsumer = new Consumer(args);
syncConsumer.runTest();
}
@@ -94,8 +94,8 @@
Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
// lookup the queue
- Queue destination = session.createQueue(_queueName);
-
+ Queue destination = (Queue) getInitialContext().lookup(_queueName);
+
// Create a MessageConsumer
System.out.println(CLASS + ": Creating a MessageConsumer");
MessageConsumer messageConsumer =
session.createConsumer(destination);
Modified:
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Producer.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Producer.java?rev=612473&r1=612472&r2=612473&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Producer.java
(original)
+++
incubator/qpid/trunk/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Producer.java
Wed Jan 16 06:45:42 2008
@@ -52,7 +52,7 @@
public static void main(String[] args)
{
_options.put("-queueName", "Queue name");
- _defaults.put("-queueName", "message_queue");
+ _defaults.put("-queueName", "direct_message_queue");
Producer producer = new Producer(args);
producer.runTest();
}
@@ -70,7 +70,7 @@
Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
// lookup the queue
- Queue destination = session.createQueue(_queueName);
+ Queue destination = (Queue) getInitialContext().lookup(_queueName);
// Create a Message producer
System.out.println(CLASS + ": Creating a Message Producer");
Modified:
incubator/qpid/trunk/qpid/java/client/example/src/main/java/runSample.sh
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/runSample.sh?rev=612473&r1=612472&r2=612473&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/example/src/main/java/runSample.sh
(original)
+++ incubator/qpid/trunk/qpid/java/client/example/src/main/java/runSample.sh
Wed Jan 16 06:45:42 2008
@@ -38,6 +38,11 @@
# Add output classes to CLASSPATH
CLASSPATH="$CLASSPATH$DIVIDER$."
+# Set VM parameters
+QPID_PARAM="$QPID_PARAM -Dlog4j.configuration=file://$QPID_SAMPLE/log4j.xml"
+
+# Set arguments
+QPID_ARGS="$QPID_ARGS -providerURL $QPID_SAMPLE/sample.properties"
# Check if the user supplied a sample classname
if test "'x$1'" = "'x'"
@@ -45,5 +50,5 @@
echo "No sample classname specified"
exit;
else
- java -cp $CLASSPATH $*
+ java -cp $CLASSPATH $QPID_PARAM $* $QPID_ARGS
fi
Added:
incubator/qpid/trunk/qpid/java/client/example/src/main/java/sample.properties
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/example/src/main/java/sample.properties?rev=612473&view=auto
==============================================================================
---
incubator/qpid/trunk/qpid/java/client/example/src/main/java/sample.properties
(added)
+++
incubator/qpid/trunk/qpid/java/client/example/src/main/java/sample.properties
Wed Jan 16 06:45:42 2008
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+java.naming.factory.initial =
org.apache.qpid.jndi.PropertiesFileInitialContextFactory
+
+# A 0.10 connection factory
+connectionfactory.ConnectionFactory = qpid:password=pass;[EMAIL
PROTECTED]:localhost:5672
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+#queue.MyQueue = example.MyQueue
+#queue.syncQueue = syncQueue
+#queue.testQueue = testQueue
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+#topic.ibmStocks = stocks.nyse.ibm
+#topic.testTopic = testTopic
+
+# Register an AMQP destination in JNDI
+# NOTE: Qpid currently only supports direct,topics and headers
+# destination.[jniName] = [BindingURL]
+destination.direct_message_queue =
direct://amq.direct/routing_key/message_queue
\ No newline at end of file