}
} else {
SessionUID sessionID = new SessionUID(lsessionid.longValue());
session = con.getSession(sessionID);
if (session == null) {
throw new BrokerException("Internal Error: client set invalid"
+ " sessionUID " + sessionID + " session does not exist");
}
}
if (blockprop_bool) { // turn off all processing
session.pause("Consumer - Block flag");
sessionPaused = true;
}
/* XXX-LKS KLUDGE FOR 2.0 compatibility */
// for now, we just pass the consumer ID back on the old
// packet .. I need to revisit this in the future
oldid = (Integer)props.get("JMQConsumerID"); // old consumer ID
if (oldid != null)
hash.put("JMQOldConsumerID", oldid);
if (props == null) {
throw new BrokerException(Globals.getBrokerResources().getString(
BrokerResources.X_INTERNAL_EXCEPTION,"no properties in addConsumer "
+ "packet - client does not match protocol"));
}
Integer inttype = (Integer )props.get("JMQDestType");
int type = (inttype == null ? -1 : inttype.intValue());
if (type == -1) {
throw new BrokerException(Globals.getBrokerResources().getString(
BrokerResources.X_INTERNAL_EXCEPTION,"Client is not sending DestType, "
+ "unable to add interest"));
}
boolean queue = DestType.isQueue(type) ;
String destination = (String)props.get("JMQDestination");
String selector = (String)props.get("JMQSelector");
Boolean nolocal = (Boolean)props.get("JMQNoLocal");
String durablename = (String)props.get("JMQDurableName");
String clientid = getClientID(props, con);
Boolean reconnect = (Boolean)props.get("JMQReconnect");
Boolean share = (Boolean)props.get("JMQShare");
Integer size = (Integer)props.get("JMQSize");
if (queue && nolocal != null && nolocal.booleanValue()) {
Globals.getLogger().log(Logger.ERROR, BrokerResources.E_INTERNAL_BROKER_ERROR,
"NoLocal is not supported on Queue Receivers");
throw new BrokerException("Unsupported property on queues JMQNoLocal "
+ "is set to " + nolocal, Status.ERROR);
}
if (reconnect != null && reconnect.booleanValue()) {
Globals.getLogger().log(Logger.ERROR,
BrokerResources.E_INTERNAL_BROKER_ERROR,
"JMQReconnect not implemented");
}
if (share != null && share.booleanValue() &&
! ClientIDHandler.CAN_USE_SHARED_CONSUMERS) {
throw new BrokerException(
Globals.getBrokerResources().getKString(
BrokerResources.X_FEATURE_UNAVAILABLE,
Globals.getBrokerResources().getKString(
BrokerResources.M_SHARED_CONS), destination),
BrokerResources.X_FEATURE_UNAVAILABLE,
(Throwable) null,
Status.NOT_ALLOWED);
}
// see if we are a wildcard destination
DestinationUID dest_uid = null;
Destination d = null;
if (DestinationUID.isWildcard(destination)) { // dont create a destination
dest_uid = DestinationUID.getUID(destination, DestType.isQueue(type));
} else {
d = null;
while (true ) {
d = Destination.getDestination(destination,
type, true /* autocreate if possible*/,
!con.isAdminConnection());
if (d.isAutoCreated())
warning = BrokerResources.W_ADD_AUTO_CONSUMER_FAILED;
try {
if (d != null)
d.incrementRefCount();
} catch (BrokerException ex) {
continue; // was destroyed in process
} catch (IllegalStateException ex) {
throw new BrokerException(
Globals.getBrokerResources().getKString(
BrokerResources.X_SHUTTING_DOWN_BROKER),
BrokerResources.X_SHUTTING_DOWN_BROKER,
ex,
Status.ERROR);
}
break; // we got one
}
if (d == null) {
// unable to autocreate destination
status = Status.NOT_FOUND;
// XXX error
throw new BrokerException(
Globals.getBrokerResources().getKString(
BrokerResources.X_DESTINATION_NOT_FOUND, destination),
BrokerResources.X_DESTINATION_NOT_FOUND,
null,
Status.NOT_FOUND);
}
dest_uid = d.getDestinationUID();
}
// Must have a clientID to add a durable
if (durablename != null && clientid == null) {
throw new BrokerException(
Globals.getBrokerResources().getKString(
BrokerResources.X_NO_CLIENTID, durablename),
BrokerResources.X_NO_CLIENTID,
null,
Status.PRECONDITION_FAILED);
}
Consumer c = null;
try {
//LKS
Consumer[] retc = createConsumer( dest_uid, con,
session, selector, clientid,
durablename, (nolocal != null && nolocal.booleanValue()),
(size == null ? -1 : size.intValue()),
(share != null && share.booleanValue()),
msg.getSysMessageID().toString(), isIndemp, true);
c = retc[0];
newc = retc[1];
sub = (Subscription)retc[2];
if (c.getPrefetch() != -1 || size != null)
hash.put("JMQSize", c.getPrefetch());
} catch (SelectorFormatException ex) {
throw new BrokerException(
Globals.getBrokerResources().getKString(
BrokerResources.W_SELECTOR_PARSE, selector),
BrokerResources.W_SELECTOR_PARSE,
ex,
Status.BAD_REQUEST);
} catch (OutOfLimitsException ex) {
if (d != null && d.isQueue()) {
String args[] = { dest_uid.getName(),
String.valueOf(d.getActiveConsumerCount()),
String.valueOf(d.getFailoverConsumerCount()) };
throw new BrokerException(
Globals.getBrokerResources().getKString(
BrokerResources.X_S_QUEUE_ATTACH_FAILED, args),
BrokerResources.X_S_QUEUE_ATTACH_FAILED,
ex,
Status.CONFLICT);
} else { // durable
String args[] = { dest_uid.getName(),
durablename, clientid,
String.valueOf(ex.getLimit()) };
throw new BrokerException(
Globals.getBrokerResources().getKString(
BrokerResources.X_S_DUR_ATTACH_FAILED, args),
BrokerResources.X_S_DUR_ATTACH_FAILED,
ex,
Status.CONFLICT);