BrokerResources.X_SHUTTING_DOWN_BROKER,
(Throwable) null,
Status.ERROR );
}
if (destinationList.get(duid) != null) {
throw new ConflictException(
Globals.getBrokerResources().getKString(
BrokerResources.X_DESTINATION_EXISTS,
duid));
}
// OK, check the persistent store (required for HA)
try {
Store pstore = Globals.getStore();
Destination d = pstore.getDestination(duid);
if (d != null) {
addDestination(d, false);
return d;
}
} catch (Exception ex) {
// ignore we want to create it
}
String lockname = null;
ClusterBroadcast mbi = Globals.getClusterBroadcast();
boolean clusterNotify = false;
Destination d = null;
try {
if (DestType.isQueue(type)) {
d = new Queue(name, type,
store, uid, autocreated);
} else {
d = new Topic(name, type,
store, uid, autocreated);
}
d.setClusterNotifyFlag(notify);
try {
synchronized (destinationList) {
Destination newd = (Destination)destinationList.get(duid);
if (newd != null) { // updating existing
throw new BrokerException("Destination already exists");
}
if (!autocreated)
d.setIsLocal(localOnly);
if (store) {
d.store();
}
destinationList.put(duid, d);
}
} catch (BrokerException ex) {
// may happen with timing of two brokers in an
// HA cluster
// if this happens, we should try to re-load the
// destination
//
// so if we get a Broker Exception, throw a new
// Conflict message
throw new BrokerException(
Globals.getBrokerResources().getKString(
BrokerResources.X_DESTINATION_EXISTS,
d.getName()),
BrokerResources.X_DESTINATION_EXISTS,
(Throwable) ex,
Status.CONFLICT );
}
clusterNotify = !d.isAutoCreated() && d.sendClusterUpdate() && notify;
if (mbi != null && clusterNotify ) { // only null in standalone tonga test
// prevents two creates at the same time
// if this is a response to a creation on another broker ..
// dont worry about locking
if (!mbi.lockDestination(duid, uid)) {
throw new ConflictException("Internal Exception:"
+ " Destination " + duid + " is in the process"
+ " of being created");
}
}
if (clusterNotify && mbi != null ) {