use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class DestinationDAOImpl method getDestination.
/**
* Get a destination.
*
* @param conn database connection
* @param destName destination's name
* @return Destination the Destination object
*/
@Override
public Destination getDestination(Connection conn, String destName) throws BrokerException {
Destination dest = null;
boolean myConn = false;
PreparedStatement pstmt = null;
ResultSet rs = null;
Exception myex = null;
try {
// Get a connection
DBManager dbMgr = DBManager.getDBManager();
if (conn == null) {
conn = dbMgr.getConnection(true);
myConn = true;
}
pstmt = dbMgr.createPreparedStatement(conn, selectSQL);
pstmt.setString(1, destName);
rs = pstmt.executeQuery();
dest = (Destination) loadData(rs, true);
} catch (Exception e) {
myex = e;
try {
if ((conn != null) && !conn.getAutoCommit()) {
conn.rollback();
}
} catch (SQLException rbe) {
logger.log(Logger.ERROR, BrokerResources.X_DB_ROLLBACK_FAILED, rbe);
}
Exception ex;
if (e instanceof BrokerException) {
throw (BrokerException) e;
} else if (e instanceof SQLException) {
ex = DBManager.wrapSQLException("[" + selectSQL + "]", (SQLException) e);
} else {
ex = e;
}
throw new BrokerException(br.getKString(BrokerResources.X_LOAD_DESTINATION_FAILED, destName), ex);
} finally {
if (myConn) {
Util.close(rs, pstmt, conn, myex);
} else {
Util.close(rs, pstmt, null, myex);
}
}
return dest;
}
use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class DestinationUtil method getVisibleTemporaryDestinations.
/*
* Returns an ArrayList of Destinations that are visible, is temporary and matches the specified connectionID.
*/
public static List getVisibleTemporaryDestinations(long connectionID) {
Iterator[] itrs = Globals.getDestinationList().getAllDestinations(null);
Iterator itr = itrs[0];
ArrayList al = new ArrayList();
while (itr.hasNext()) {
Destination oneDest = (Destination) itr.next();
if (!isVisibleDestination(oneDest)) {
continue;
}
if (!oneDest.isTemporary()) {
continue;
}
ConnectionUID cxnId = oneDest.getConnectionUID();
if (cxnId == null) {
continue;
}
if (!(cxnId.longValue() == connectionID)) {
continue;
}
al.add(oneDest);
}
return (al);
}
use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class DestinationUtil method pauseAllDestinations.
public static void pauseAllDestinations(int internalPauseType) {
Iterator[] itrs = Globals.getDestinationList().getAllDestinations(null);
// PART
Iterator itr = itrs[0];
while (itr.hasNext()) {
Destination d = (Destination) itr.next();
/*
* Skip internal, admin, or temp destinations. Skipping temp destinations may need to be revisited.
*/
if (d.isInternal() || d.isAdmin() || d.isTemporary()) {
continue;
}
d.pauseDestination(internalPauseType);
}
}
use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class DestinationUtil method createDestination.
@SuppressWarnings("deprecation")
public static void createDestination(DestinationInfo info) throws BrokerException {
String errMsg = null;
int status = Status.OK;
BrokerResources rb = Globals.getBrokerResources();
Logger logger = Globals.getLogger();
// Default attributes of the destination
int type = DestType.DEST_TYPE_QUEUE | DestType.DEST_FLAVOR_SINGLE;
int maxMessages = -1;
SizeString maxMessageBytes = null;
SizeString maxMessageSize = null;
if (MemoryGlobals.getMEM_DISALLOW_CREATE_DEST()) {
status = Status.ERROR;
errMsg = rb.W_LOW_MEM_REJECT_DEST;
} else if (info.isModified(DestinationInfo.NAME)) {
if (info.isModified(DestinationInfo.TYPE)) {
type = info.type;
}
if (info.isModified(DestinationInfo.MAX_MESSAGES)) {
maxMessages = info.maxMessages;
}
if (info.isModified(DestinationInfo.MAX_MESSAGE_BYTES)) {
maxMessageBytes = new SizeString();
maxMessageBytes.setBytes(info.maxMessageBytes);
}
if (info.isModified(DestinationInfo.MAX_MESSAGE_SIZE)) {
maxMessageSize = new SizeString();
maxMessageSize.setBytes(info.maxMessageSize);
}
} else {
status = Status.ERROR;
errMsg = rb.X_NO_DEST_NAME_SET;
}
// XXX create destination
if (status == Status.OK) {
if (DestType.destNameIsInternal(info.name)) {
status = Status.ERROR;
errMsg = rb.getKString(rb.X_CANNOT_CREATE_INTERNAL_DEST, info.name, DestType.INTERNAL_DEST_PREFIX);
} else {
if (CreateDestinationHandler.isValidDestinationName(info.name)) {
try {
Globals.getDestinationList().createDestination(null, info.name, type);
} catch (Exception ex) {
status = Status.ERROR;
errMsg = rb.getString(rb.X_CREATE_DEST_EXCEPTION, info.name, getMessageFromException(ex));
if (ex instanceof ConflictException) {
logger.log(Logger.INFO, errMsg, ex);
} else {
logger.logStack(Logger.INFO, errMsg, ex);
}
}
} else {
status = Status.ERROR;
errMsg = rb.getKString(rb.X_DEST_NAME_INVALID, info.name);
}
}
}
if (status == Status.OK) {
try {
Destination[] ds = Globals.getDestinationList().getDestination(null, info.name, DestType.isQueue(type));
Destination d = ds[0];
d.setCapacity(maxMessages);
d.setByteCapacity(maxMessageBytes);
d.setMaxByteSize(maxMessageSize);
if (info.isModified(info.DEST_SCOPE)) {
int scope = info.destScope;
d.setScope(scope);
}
if (info.isModified(info.DEST_LIMIT)) {
int destlimit = info.destLimitBehavior;
d.setLimitBehavior(destlimit);
}
if (info.isModified(info.DEST_PREFETCH)) {
int prefetch = info.maxPrefetch;
d.setMaxPrefetch(prefetch);
}
if (info.isModified(info.DEST_CDP)) {
int clusterdeliverypolicy = info.destCDP;
d.setClusterDeliveryPolicy(clusterdeliverypolicy);
}
if (info.isModified(info.MAX_ACTIVE_CONSUMERS)) {
int maxcons = info.maxActiveConsumers;
d.setMaxActiveConsumers(maxcons);
}
if (info.isModified(info.MAX_PRODUCERS)) {
int maxp = info.maxProducers;
d.setMaxProducers(maxp);
}
if (info.isModified(info.MAX_FAILOVER_CONSUMERS)) {
int maxcons = info.maxFailoverConsumers;
d.setMaxFailoverConsumers(maxcons);
}
if (info.isModified(info.MAX_SHARED_CONSUMERS)) {
int maxsharedcons = info.maxNumSharedConsumers;
d.setMaxSharedConsumers(maxsharedcons);
}
if (info.isModified(info.SHARE_FLOW_LIMIT)) {
int sflowlimit = info.sharedConsumerFlowLimit;
d.setSharedFlowLimit(sflowlimit);
}
if (info.isModified(info.USE_DMQ)) {
boolean dmq = info.useDMQ;
d.setUseDMQ(dmq);
}
d.update();
/*
* // audit logging for create destination Globals.getAuditSession().destinationOperation( con.getUserName(),
* con.remoteHostString(), MQAuditSession.CREATE_DESTINATION, d.isQueue()?MQAuditSession.QUEUE:MQAuditSession.TOPIC,
* d.getDestinationName());
*/
} catch (Exception ex) {
// remove the destination
try {
DestinationUID duid = DestinationUID.getUID(info.name, DestType.isQueue(type));
Globals.getDestinationList().removeDestination(null, duid, false, ex.toString());
} catch (Exception ex1) {
// if we cant destroy .. its ok .. ignore the exception
}
status = Status.ERROR;
errMsg = rb.getString(rb.X_UPDATE_DEST_EXCEPTION, info.name, getMessageFromException(ex));
logger.log(Logger.WARNING, errMsg, ex);
}
}
if (status != Status.OK) {
throw new BrokerException(errMsg);
}
}
use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class DestinationUtil method getVisibleDestinations.
/*
* Returns an ArrayList of Destinations that are visible to the outside
*/
public static List getVisibleDestinations() {
Iterator[] itrs = Globals.getDestinationList().getAllDestinations(null);
Iterator itr = itrs[0];
ArrayList al = new ArrayList();
while (itr.hasNext()) {
Destination oneDest = (Destination) itr.next();
if (!isVisibleDestination(oneDest)) {
continue;
}
al.add(oneDest);
}
return (al);
}
Aggregations