diff options
author | Rajith Muditha Attapattu <rajith@apache.org> | 2008-01-29 22:24:40 +0000 |
---|---|---|
committer | Rajith Muditha Attapattu <rajith@apache.org> | 2008-01-29 22:24:40 +0000 |
commit | 8dcb1d30b0414a3aa139dd93319ce2fe42c9049a (patch) | |
tree | 5f286162828adea0cdb35a706749e210a0e94372 /qpid/java/client/example | |
parent | 36be90284d42e77e4cfb18a08d3b1f0694afed35 (diff) | |
download | qpid-python-8dcb1d30b0414a3aa139dd93319ce2fe42c9049a.tar.gz |
added support to notify connection.close to the JMSExceptionListener
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@616542 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/client/example')
-rw-r--r-- | qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Producer.java | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Producer.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Producer.java index 9cbd40f9ea..1e1390941f 100644 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Producer.java +++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Producer.java @@ -25,6 +25,8 @@ import java.util.Properties; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; +import javax.jms.ExceptionListener; +import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageProducer; import javax.jms.Session; @@ -32,6 +34,12 @@ import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; +import org.apache.qpid.client.AMQDestination; +import org.apache.qpid.client.AMQQueue; +import org.apache.qpid.client.AMQSession_0_10; +import org.apache.qpidity.nclient.Client; +import org.apache.qpidity.transport.Option; + /** * Message producer example, sends message to a queue. */ @@ -73,13 +81,22 @@ public class Producer Context ctx = new InitialContext(properties); // look up destination - Destination destination = (Destination)ctx.lookup("directQueue"); + //Destination destination = (Destination)ctx.lookup("directQueue"); + Destination destination = new AMQQueue("amq.fancy","myQeueu"); // Lookup the connection factory ConnectionFactory conFac = (ConnectionFactory)ctx.lookup("qpidConnectionfactory"); // create the connection Connection connection = conFac.createConnection(); + connection.setExceptionListener(new ExceptionListener() + { + public void onException(JMSException e) + { + e.printStackTrace(); + } + }); + // Create a session on the connection // This session is a default choice of non-transacted and uses the auto acknowledge feature of a session. System.out.println(CLASS + ": Creating a non-transacted, auto-acknowledged session"); @@ -92,6 +109,17 @@ public class Producer System.out.println(CLASS + ": Creating a Message Producer"); MessageProducer messageProducer = session.createProducer(destination); + try{ + org.apache.qpidity.nclient.Connection con = Client.createConnection(); + con.connect("qpid:password=pass;username=name@tcp:localhost:5672"); + org.apache.qpidity.nclient.Session ses = con.createSession(1000000); + ses.exchangeDelete("amq.direct", Option.NO_OPTION); + } + catch(Exception e) + { + e.printStackTrace(); + } + // Create a Message TextMessage message; System.out.println(CLASS + ": Creating a TestMessage to send to the destination"); |