Github user gemmellr commented on a diff in the pull request:
https://github.com/apache/qpid-jms/pull/6#discussion_r115539336
--- Diff:
qpid-jms-examples/src/main/java/org/apache/qpid/jms/example/Client.java ---
@@ -0,0 +1,204 @@
+
+package org.apache.qpid.jms.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TemporaryQueue;
+import javax.jms.TextMessage;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Scanner;
+
+public class Client {
+ private static final int DELIVERY_MODE = DeliveryMode.NON_PERSISTENT;
+ public static void main(String[] args) throws Exception {
+ try {
+ // The configuration for the Qpid InitialContextFactory has
been supplied in
+ // a jndi.properties file in the classpath, which results in
it being picked
+ // up automatically by the InitialContext constructor.
+ Context context = new InitialContext();
+
+ ConnectionFactory factory = (ConnectionFactory)
context.lookup("myFactoryLookup");
+ Destination queue = (Destination)
context.lookup("myQueueLookup");
+
+ Connection connection =
factory.createConnection(System.getProperty("USER"),
System.getProperty("PASSWORD"));
+ connection.setExceptionListener(new MyExceptionListener());
+ connection.start();
+
+ Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
+
+ //Create message and temporary queue to send to and from.
+ Message messageToBeSent = userInterface(session);
+ TemporaryQueue tempQ = session.createTemporaryQueue();
+ messageToBeSent.setJMSReplyTo(tempQ);
+
+ MessageProducer messageProducer =
session.createProducer(queue);
+
+ //Send the message
+ messageProducer.send(messageToBeSent, DELIVERY_MODE,
Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
+ System.out.println("[CLIENT] The message has been sent.");
+
+
+ MessageConsumer messageConsumer =
session.createConsumer(tempQ);
+ long start = System.currentTimeMillis();
+ boolean deductTimeout = false;
+ int timeout = 1000;
+
+ //Receive the server response
+ TextMessage newMessage = (TextMessage)
messageConsumer.receive(timeout);
+ if (newMessage != null) {
+ System.out.print("[CLIENT] Response from server
received in ");
+ } else {
+ System.out.println("[CLIENT] Response not received within
timeout, stopping.");
+ deductTimeout = true;
+ }
+
+ long finish = System.currentTimeMillis();
+ long taken = finish - start;
+ if (deductTimeout) {
+ taken -= timeout;
+ }
+ if (newMessage != null) {
+ System.out.println(taken + "ms");
--- End diff --
I would probably just remove the timing stuff. The Sender+Reciever examples
only have that as they can serve as simple throughput checks, it isnt likely to
be that interesting in this case.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]