User: pkendall
Date: 01/08/09 01:16:54
Modified: src/main/org/jbossmq/server ClientConsumer.java
Log:
no message
Revision Changes Path
1.17 +47 -74 jbossmq/src/main/org/jbossmq/server/ClientConsumer.java
Index: ClientConsumer.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jbossmq/server/ClientConsumer.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ClientConsumer.java 2001/08/09 01:18:28 1.16
+++ ClientConsumer.java 2001/08/09 08:16:54 1.17
@@ -25,7 +25,7 @@
*
* @author Hiram Chirino ([EMAIL PROTECTED])
*
- * @version $Revision: 1.16 $
+ * @version $Revision: 1.17 $
*/
public class ClientConsumer implements Runnable {
@@ -37,12 +37,12 @@
ConnectionToken dc;
//Is this connection enabled (Can we transmit to the receiver)
boolean enabled;
- //Has this connection been closed?
- boolean closed = false;
+ //Has this connection been closed?
+ boolean closed = false;
//Maps a a subsction id to a Subscription
- HashMap subscriptions = new HashMap();
+ HashMap subscriptions = new HashMap();
- LinkedList blockedSubscriptions = new LinkedList();
+ LinkedList blockedSubscriptions = new LinkedList();
//LinkedList of the the temporary destinations that this client created
// public LinkedList temporaryDestinations = new LinkedList();
//The message push thread for this consumer connection
@@ -56,26 +56,26 @@
cat =
org.apache.log4j.Category.getInstance(ClientConsumer.class.getName()+":"+dc.getClientID());
messagePushThread = new Thread(server.threadGroup, this, "Message
Pusher "+dc.getClientID());
messagePushThread.setDaemon(true);
- messagePushThread.start();
+ messagePushThread.start();
}
- public void queueMessageForSending(ReceiveRequest r){
- synchronized(messages){
- messages.add(r);
- messages.notify();
- }
- }
+ public void queueMessageForSending(ReceiveRequest r){
+ synchronized(messages){
+ messages.add(r);
+ messages.notify();
+ }
+ }
public void addSubscription(Subscription req) throws JMSException
{
cat.debug("Adding subscription for: "+req);
req.dc = dc;
- req.clientConsumer = this;
+ req.clientConsumer = this;
JMSDestination
jmsdest=(JMSDestination)server.getJMSDestination(req.destination);
if (jmsdest==null) throw new JMSException("This destination does not
exist !");
- jmsdest.addSubscriber(req);
+ jmsdest.addSubscriber(req);
synchronized (subscriptions ) {
HashMap subscriptionsClone = (HashMap)subscriptions.clone();
@@ -88,10 +88,10 @@
cat.debug(""+this+"->close()");
- synchronized(messages){
- closed = true;
- messages.notifyAll();
- }
+ synchronized(messages){
+ closed = true;
+ messages.notifyAll();
+ }
synchronized (subscriptions) {
Iterator i = subscriptions.keySet().iterator();
@@ -106,34 +106,6 @@
}
-// public void listenerChange(int subscriberId, boolean state) throws
JMSException {
-//
-// cat.debug(""+this+"->listenerChange(subscriberId="+subscriberId+",
state="+state+")");
-//
-// Subscription req = (Subscription)subscriptions.get(new
Integer(subscriberId));
-// if( req == null )
-// throw new JMSException("The provided subscription does not
exist");
-//
-// JMSDestination queue = server.getJMSDestination(req.destination);
-// if( queue == null )
-// throw new JMSException("The subscription's destination does
not exist");
-//
-// if(state){
-// if(enabled){
-// queue.addReceiver(req);
-// }else{
-// blockedSubscriptions.remove(req);
-// }
-// }else{
-// if(enabled){
-// queue.removeReceiver(req);
-// }else{
-// blockedSubscriptions.remove(req);
-// }
-// }
-//
-// }
-
public SpyMessage receive(int subscriberId, long wait) throws JMSException {
Subscription req = (Subscription)subscriptions.get(new
Integer(subscriberId));
@@ -144,16 +116,17 @@
if( queue == null )
throw new JMSException("The subscription's destination does
not exist");
- if(enabled){
- return queue.receive(req,(wait != -1));
- }else if(wait != -1){
- blockedSubscriptions.add(req);
- }
+ if(enabled) {
+ return queue.receive(req,(wait != -1));
+ }
+ else if(wait != -1) {
+ blockedSubscriptions.add(req);
+ }
return null;
}
- public void acknowledge(AcknowledgementRequest request, org.jbossmq.pm.Tx txId)
throws JMSException{
+ public void acknowledge(AcknowledgementRequest request, org.jbossmq.pm.Tx
txId) throws JMSException{
Subscription sub = (Subscription)subscriptions.get(new
Integer(request.subscriberId));
if( sub == null )
throw new JMSException("The provided subscription does not
exist");
@@ -162,8 +135,8 @@
if( queue == null )
throw new JMSException("The subscription's destination does
not exist");
- queue.acknowledge(request,sub,txId);
- }
+ queue.acknowledge(request,sub,txId);
+ }
public void removeSubscription(int subscriptionId) throws JMSException
@@ -178,12 +151,12 @@
subscriptions = subscriptionsClone;
}
- if( req == null )
- throw new JMSException("The subscription had not been previously registered");
+ if( req == null )
+ throw new JMSException("The subscription had not been
previously registered");
- JMSDestination queue=(JMSDestination)server.getJMSDestination(req.destination);
- if (queue==null)
- throw new JMSException("The subscription was registed with a destination that
does not exist !");
+ JMSDestination
queue=(JMSDestination)server.getJMSDestination(req.destination);
+ if (queue==null)
+ throw new JMSException("The subscription was registed with a
destination that does not exist !");
queue.removeSubscriber(req);
}
@@ -204,8 +177,8 @@
}
catch( InterruptedException e ) {
}
- if(closed)
- return;
+ if(closed)
+ return;
}
job=new ReceiveRequest[messages.size()];
@@ -230,18 +203,18 @@
public void setEnabled(boolean enabled) throws JMSException {
cat.debug(""+this+"->setEnabled(enabled="+enabled+")");
this.enabled = enabled;
- if(enabled){
- // queues might be waiting for messages.
- synchronized(blockedSubscriptions){
- for(Iterator it = blockedSubscriptions.iterator();it.hasNext();){
- Subscription sub = (Subscription) it.next();
- JMSDestination dest = server.getJMSDestination(sub.destination);
- if(dest != null)
- dest.addReceiver(sub);
- }
- blockedSubscriptions.clear();
- }
- }
+ if(enabled) {
+ // queues might be waiting for messages.
+ synchronized(blockedSubscriptions) {
+ for(Iterator it =
blockedSubscriptions.iterator();it.hasNext();) {
+ Subscription sub = (Subscription) it.next();
+ JMSDestination dest =
server.getJMSDestination(sub.destination);
+ if(dest != null)
+ dest.addReceiver(sub);
+ }
+ blockedSubscriptions.clear();
+ }
+ }
}
public String toString() {
@@ -250,4 +223,4 @@
org.apache.log4j.Category cat;
-}
\ No newline at end of file
+}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development