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 | 596376457b8a65bd2f263201a21e29ab0d565028 (patch) | |
| tree | a67ca77e10e8b31777ea33d6b4577d08b34e1511 /java/client/example/src | |
| parent | 1fd398c1c0b78ce48d3b540698cfbf085e5ff8dd (diff) | |
| download | qpid-python-596376457b8a65bd2f263201a21e29ab0d565028.tar.gz | |
added support to notify connection.close to the JMSExceptionListener
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@616542 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client/example/src')
| -rw-r--r-- | 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/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Producer.java b/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Producer.java index 9cbd40f9ea..1e1390941f 100644 --- a/java/client/example/src/main/java/org/apache/qpid/example/jmsexample/direct/Producer.java +++ b/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"); |
