summaryrefslogtreecommitdiff
path: root/qpid/java/client/example
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2008-04-16 13:32:13 +0000
committerRafael H. Schloming <rhs@apache.org>2008-04-16 13:32:13 +0000
commitbbe30c7875f67547ea9394d4e99b420ac22ef152 (patch)
tree3bd76d813efccb16ba86f49982e3f24725659174 /qpid/java/client/example
parent857ba162eba08e8c210492a0ea265a6bd4439467 (diff)
downloadqpid-python-bbe30c7875f67547ea9394d4e99b420ac22ef152.tar.gz
QPID-901: updates to the java client to use the 0-10 final spec instead of the 0-10 preview spec; this includes improvements to the codegen process as well as some modifications to the shared code path in the client to not lose per message state when consumers are closed.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@648692 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/client/example')
-rwxr-xr-xqpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DeclareQueue.java4
-rwxr-xr-xqpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DirectProducer.java8
-rwxr-xr-xqpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/Listener.java9
-rwxr-xr-xqpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/DeclareQueue.java4
-rwxr-xr-xqpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/FannoutProducer.java8
-rwxr-xr-xqpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/Listener.java11
-rwxr-xr-xqpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicListener.java14
-rwxr-xr-xqpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicPublisher.java8
8 files changed, 41 insertions, 25 deletions
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DeclareQueue.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DeclareQueue.java
index a9257ccf70..8bb27847ce 100755
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DeclareQueue.java
+++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DeclareQueue.java
@@ -31,13 +31,13 @@ public class DeclareQueue
// declare and bind queue
session.queueDeclare("message_queue", null, null);
- session.queueBind("message_queue", "amq.direct", "routing_key", null);
+ session.exchangeBind("message_queue", "amq.direct", "routing_key", null);
// confirm completion
session.sync();
//cleanup
- session.sessionClose();
+ session.sessionDetach(session.getName());
try
{
con.close();
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DirectProducer.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DirectProducer.java
index 7c27051fb2..7329792a2b 100755
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DirectProducer.java
+++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/DirectProducer.java
@@ -8,6 +8,8 @@ import org.apache.qpidity.nclient.Connection;
import org.apache.qpidity.nclient.Session;
import org.apache.qpidity.nclient.util.MessageListener;
import org.apache.qpidity.transport.DeliveryProperties;
+import org.apache.qpidity.transport.MessageAcceptMode;
+import org.apache.qpidity.transport.MessageAcquireMode;
public class DirectProducer implements MessageListener
{
@@ -65,13 +67,13 @@ public class DirectProducer implements MessageListener
for (int i=0; i<10; i++)
{
- session.messageTransfer("amq.direct", Session.TRANSFER_CONFIRM_MODE_REQUIRED, Session.TRANSFER_ACQUIRE_MODE_PRE_ACQUIRE);
+ session.messageTransfer("amq.direct", MessageAcceptMode.EXPLICIT,MessageAcquireMode.PRE_ACQUIRED);
session.header(deliveryProps);
session.data("Message " + i);
session.endData();
}
- session.messageTransfer("amq.direct", Session.TRANSFER_CONFIRM_MODE_REQUIRED, Session.TRANSFER_ACQUIRE_MODE_PRE_ACQUIRE);
+ session.messageTransfer("amq.direct", MessageAcceptMode.EXPLICIT, MessageAcquireMode.PRE_ACQUIRED);
session.header(deliveryProps);
session.data("That's all, folks!");
session.endData();
@@ -80,7 +82,7 @@ public class DirectProducer implements MessageListener
session.sync();
//cleanup
- session.sessionClose();
+ session.sessionDetach(session.getName());
try
{
con.close();
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/Listener.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/Listener.java
index 244dbdbeae..b199c3a69a 100755
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/Listener.java
+++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/direct/Listener.java
@@ -9,6 +9,8 @@ import org.apache.qpidity.nclient.Session;
import org.apache.qpidity.nclient.util.MessageListener;
import org.apache.qpidity.nclient.util.MessagePartListenerAdapter;
+import org.apache.qpidity.transport.MessageCreditUnit;
+
/**
* This listens to messages on a queue and terminates
* when it sees the final message
@@ -84,8 +86,9 @@ public class Listener implements MessageListener
// issue credits
- session.messageFlow("listener_destination", Session.MESSAGE_FLOW_UNIT_BYTE, Session.MESSAGE_FLOW_MAX_BYTES);
- session.messageFlow("listener_destination", Session.MESSAGE_FLOW_UNIT_MESSAGE, 11);
+ // XXX
+ session.messageFlow("listener_destination", MessageCreditUnit.BYTE, Session.MESSAGE_FLOW_MAX_BYTES);
+ session.messageFlow("listener_destination", MessageCreditUnit.MESSAGE, 11);
// confirm completion
session.sync();
@@ -96,7 +99,7 @@ public class Listener implements MessageListener
session.messageCancel("listener_destination");
//cleanup
- session.sessionClose();
+ session.sessionDetach(session.getName());
try
{
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/DeclareQueue.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/DeclareQueue.java
index cb49e9d28f..67f24148d8 100755
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/DeclareQueue.java
+++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/DeclareQueue.java
@@ -31,13 +31,13 @@ public class DeclareQueue
// declare and bind queue
session.queueDeclare("message_queue", null, null);
- session.queueBind("message_queue", "amq.fanout",null, null);
+ session.exchangeBind("message_queue", "amq.fanout",null, null);
// confirm completion
session.sync();
//cleanup
- session.sessionClose();
+ session.sessionDetach(session.getName());
try
{
con.close();
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/FannoutProducer.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/FannoutProducer.java
index 1dfc468cd4..4c647fde36 100755
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/FannoutProducer.java
+++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/FannoutProducer.java
@@ -4,6 +4,8 @@ import org.apache.qpidity.nclient.Client;
import org.apache.qpidity.nclient.Connection;
import org.apache.qpidity.nclient.Session;
import org.apache.qpidity.transport.DeliveryProperties;
+import org.apache.qpidity.transport.MessageAcceptMode;
+import org.apache.qpidity.transport.MessageAcquireMode;
public class FannoutProducer
{
@@ -32,13 +34,13 @@ public class FannoutProducer
for (int i=0; i<10; i++)
{
- session.messageTransfer("amq.fanout", Session.TRANSFER_CONFIRM_MODE_REQUIRED, Session.TRANSFER_ACQUIRE_MODE_PRE_ACQUIRE);
+ session.messageTransfer("amq.fanout", MessageAcceptMode.EXPLICIT, MessageAcquireMode.PRE_ACQUIRED);
session.header(deliveryProps);
session.data("Message " + i);
session.endData();
}
- session.messageTransfer("amq.fanout", Session.TRANSFER_CONFIRM_MODE_REQUIRED, Session.TRANSFER_ACQUIRE_MODE_PRE_ACQUIRE);
+ session.messageTransfer("amq.fanout", MessageAcceptMode.EXPLICIT, MessageAcquireMode.PRE_ACQUIRED);
session.header(deliveryProps);
session.data("That's all, folks!");
session.endData();
@@ -47,7 +49,7 @@ public class FannoutProducer
session.sync();
//cleanup
- session.sessionClose();
+ session.sessionDetach(session.getName());
try
{
con.close();
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/Listener.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/Listener.java
index cf12e80b5c..1feb5cfe23 100755
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/Listener.java
+++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/fanout/Listener.java
@@ -9,6 +9,10 @@ import org.apache.qpidity.nclient.Session;
import org.apache.qpidity.nclient.util.MessageListener;
import org.apache.qpidity.nclient.util.MessagePartListenerAdapter;
+import org.apache.qpidity.transport.MessageAcceptMode;
+import org.apache.qpidity.transport.MessageAcquireMode;
+import org.apache.qpidity.transport.MessageCreditUnit;
+
/**
* This listens to messages on a queue and terminates
* when it sees the final message
@@ -83,8 +87,9 @@ public class Listener implements MessageListener
// issue credits
- session.messageFlow("listener_destination", Session.MESSAGE_FLOW_UNIT_BYTE, Session.MESSAGE_FLOW_MAX_BYTES);
- session.messageFlow("listener_destination", Session.MESSAGE_FLOW_UNIT_MESSAGE, 11);
+ // XXX
+ session.messageFlow("listener_destination", MessageCreditUnit.BYTE, Session.MESSAGE_FLOW_MAX_BYTES);
+ session.messageFlow("listener_destination", MessageCreditUnit.MESSAGE, 11);
// confirm completion
session.sync();
@@ -95,7 +100,7 @@ public class Listener implements MessageListener
session.messageCancel("listener_destination");
//cleanup
- session.sessionClose();
+ session.sessionDetach(session.getName());
try
{
con.close();
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicListener.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicListener.java
index e5c560860e..f26e5418b4 100755
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicListener.java
+++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicListener.java
@@ -8,6 +8,7 @@ import org.apache.qpidity.nclient.Connection;
import org.apache.qpidity.nclient.Session;
import org.apache.qpidity.nclient.util.MessageListener;
import org.apache.qpidity.nclient.util.MessagePartListenerAdapter;
+import org.apache.qpidity.transport.MessageCreditUnit;
import org.apache.qpidity.transport.Option;
@@ -44,11 +45,11 @@ public class TopicListener implements MessageListener
}
}
- public void prepareQueue(Session session,String queueName,String routingKey)
+ public void prepareQueue(Session session,String queueName,String bindingKey)
{
session.queueDeclare(queueName, null, null, Option.EXCLUSIVE, Option.AUTO_DELETE);
- session.queueBind(queueName, "amq.topic", routingKey, null);
- session.queueBind(queueName, "amq.topic", "control", null);
+ session.exchangeBind(queueName, "amq.topic", bindingKey, null);
+ session.exchangeBind(queueName, "amq.topic", "control", null);
session.messageSubscribe(queueName,queueName,
Session.TRANSFER_CONFIRM_MODE_NOT_REQUIRED,
@@ -56,8 +57,9 @@ public class TopicListener implements MessageListener
new MessagePartListenerAdapter(this),
null, Option.NO_OPTION);
// issue credits
- session.messageFlow(queueName, Session.MESSAGE_FLOW_UNIT_BYTE, Session.MESSAGE_FLOW_MAX_BYTES);
- session.messageFlow(queueName, Session.MESSAGE_FLOW_UNIT_MESSAGE, 24);
+ // XXX: need to be able to set to null
+ session.messageFlow(queueName, MessageCreditUnit.BYTE, Session.MESSAGE_FLOW_MAX_BYTES);
+ session.messageFlow(queueName, MessageCreditUnit.MESSAGE, 24);
}
public void cancelSubscription(Session session,String dest)
@@ -106,7 +108,7 @@ public class TopicListener implements MessageListener
listener.cancelSubscription(session,"weather");
//cleanup
- session.sessionClose();
+ session.sessionDetach(session.getName());
try
{
con.close();
diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicPublisher.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicPublisher.java
index b33a6b967b..c960643504 100755
--- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicPublisher.java
+++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/amqpexample/pubsub/TopicPublisher.java
@@ -4,6 +4,8 @@ import org.apache.qpidity.nclient.Client;
import org.apache.qpidity.nclient.Connection;
import org.apache.qpidity.nclient.Session;
import org.apache.qpidity.transport.DeliveryProperties;
+import org.apache.qpidity.transport.MessageAcceptMode;
+import org.apache.qpidity.transport.MessageAcquireMode;
public class TopicPublisher
{
@@ -16,7 +18,7 @@ public class TopicPublisher
deliveryProps.setRoutingKey(routing_key);
for (int i=0; i<5; i++) {
- session.messageTransfer("amq.topic", Session.TRANSFER_CONFIRM_MODE_NOT_REQUIRED,Session.TRANSFER_ACQUIRE_MODE_PRE_ACQUIRE);
+ session.messageTransfer("amq.topic", MessageAcceptMode.EXPLICIT, MessageAcquireMode.PRE_ACQUIRED);
session.header(deliveryProps);
session.data("Message " + i);
session.endData();
@@ -26,7 +28,7 @@ public class TopicPublisher
public void noMoreMessages(Session session)
{
- session.messageTransfer("amq.topic", Session.TRANSFER_CONFIRM_MODE_REQUIRED, Session.TRANSFER_ACQUIRE_MODE_PRE_ACQUIRE);
+ session.messageTransfer("amq.topic", MessageAcceptMode.EXPLICIT, MessageAcquireMode.PRE_ACQUIRED);
session.header(new DeliveryProperties().setRoutingKey("control"));
session.data("That's all, folks!");
session.endData();
@@ -61,7 +63,7 @@ public class TopicPublisher
session.sync();
//cleanup
- session.sessionClose();
+ session.sessionDetach(session.getName());
try
{
con.close();