use of com.sun.messaging.jmq.jmsserver.util.BrokerException in project openmq by eclipse-ee4j.
the class ProtocolImpl method pauseSession.
/**
* Pause a session
* <P>
* Packet:<B>STOP</b>
* </p>
*
* @param uid session to pause
*/
@Override
public void pauseSession(SessionUID uid) throws BrokerException {
Session ses = Session.getSession(uid);
if (ses == null) {
throw new BrokerException("No session for " + uid);
}
ses.pause("PROTOCOL");
}
use of com.sun.messaging.jmq.jmsserver.util.BrokerException in project openmq by eclipse-ee4j.
the class ProtocolImpl method startTransaction.
/**
* Start a transaction.
*
* @param xid The Xid of the transaction to start. Required if transaction is an XA transaction. Must be null if it is
* not an XA transaction.
* @param xaFlags xaFlags passed on START operation. Used only if an XA transaction.
* @param con Connection client start packet came in on (or null if internal)
* @param type how rollback should be handled (e.g. only not prepared)
* @param lifetime how long the transaction should live (0 == forever)
* @return The TransactionUID started
*/
@Override
public TransactionUID startTransaction(JMQXid xid, Integer xaFlags, AutoRollbackType type, long lifetime, IMQConnection con) throws BrokerException {
if (DEBUG) {
logger.log(Logger.INFO, "ProtocolImpl.START TRANSACTION:XID=" + xid + ", xaFlags=" + TransactionState.xaFlagToString(xaFlags) + ", type=" + type + ", lifetime=" + lifetime + ", conn=@" + con.hashCode() + "[" + con.getConnectionUID() + ", " + con + "]");
}
List conlist = con.getTransactionListThreadSafe();
TransactionHandler handler = (TransactionHandler) pr.getHandler(PacketType.START_TRANSACTION);
// allocated a TID
TransactionUID id = null;
TransactionList tl = null;
if (xaFlags == null || TransactionState.isFlagSet(XAResource.TMNOFLAGS, xaFlags)) {
id = new TransactionUID();
TransactionList[] tls = DL.getTransactionList(con.getPartitionedStore());
tl = tls[0];
if (tl == null) {
throw new BrokerException("No transaction List for connection " + con + " to start new transaction " + id + (xid == null ? "" : " XID=" + xid));
}
} else if (xid != null) {
Object[] oo = TransactionList.mapXidToTid(xid, con);
if (oo == null) {
throw new BrokerException("Unknown XID " + xid, Status.NOT_FOUND);
} else {
tl = (TransactionList) oo[0];
id = (TransactionUID) oo[1];
}
} else {
// XID is null, something is wrong
throw new BrokerException("Invalid xid");
}
if (tl == null) {
Object[] oo = TransactionList.getTransListAndState(id, con, false, false);
if (oo != null) {
tl = (TransactionList) oo[0];
}
}
if (tl == null) {
throw new BrokerException("No Transaction List found for connection " + con + " to start transaction " + id + (xid == null ? "" : " XID=" + xid));
}
Object o = new Object();
handler.doStart(tl, id, conlist, con, type, xid, xid != null, lifetime, 0, xaFlags, PacketType.START_TRANSACTION, false, o.toString());
if (DEBUG) {
logger.log(Logger.INFO, "ProtocolImpl.STARTED TRANSACTION:TID=" + id + ", XID=" + xid + ", type=" + type + ", con=" + con);
}
return id;
}
use of com.sun.messaging.jmq.jmsserver.util.BrokerException in project openmq by eclipse-ee4j.
the class ProtocolImpl method commitTransaction.
/**
* Commit a transaction.
*
* @param id The TransactionUID to commit
* @param xid The Xid of the transaction to commit. Required if transaction is an XA transaction. Must be null if it is
* not an XA transaction.
* @param xaFlags xaFlags passed on COMMIT operation. Used only if an XA transaction.
* @param con Connection client commit packet came in on (or null if internal)
*/
@Override
public void commitTransaction(TransactionUID id, JMQXid xid, Integer xaFlags, IMQConnection con) throws BrokerException {
if (DEBUG) {
logger.log(Logger.INFO, "ProtocolImpl.COMMIT TRANSACTION:TID=" + id + ", XID=" + xid + ", xaFlags=" + TransactionState.xaFlagToString(xaFlags) + ", conn=@" + con.hashCode() + "[" + con.getConnectionUID() + ", " + con + "]");
}
List conlist = con.getTransactionListThreadSafe();
TransactionHandler handler = (TransactionHandler) pr.getHandler(PacketType.START_TRANSACTION);
TransactionList tl = null;
if (0L == id.longValue()) {
if (xid == null) {
throw new BrokerException("Unexpected TransactionUID " + id);
}
Object[] oo = TransactionList.mapXidToTid(xid, con);
if (oo == null) {
id = null;
} else {
tl = (TransactionList) oo[0];
id = (TransactionUID) oo[1];
}
if (id == null) {
throw new BrokerException("Unknown XID " + xid, Status.NOT_FOUND);
}
}
TransactionState ts = null;
if (tl == null) {
Object[] oo = TransactionList.getTransListAndState(id, con, false, false);
if (oo != null) {
tl = (TransactionList) oo[0];
ts = (TransactionState) oo[1];
}
}
if (tl == null) {
throw new BrokerException("Unknown transaction " + id + (xid == null ? "" : " XID=" + xid), Status.NOT_FOUND);
}
if (ts == null) {
ts = tl.retrieveState(id);
if (ts == null) {
throw new BrokerException("Unknown transaction " + id + (xid == null ? "" : " XID=" + xid), Status.NOT_FOUND);
}
}
if (xid != null) {
if (ts.getXid() == null || !xid.equals(ts.getXid())) {
throw new BrokerException("Transaction XID mismatch " + xid + ", expected " + ts.getXid() + " for transaction " + id);
}
}
handler.doCommit(tl, id, xid, xaFlags, ts, conlist, false, con, null);
}
use of com.sun.messaging.jmq.jmsserver.util.BrokerException in project openmq by eclipse-ee4j.
the class Agent method getPlatformMBeanServer.
private MBeanServer getPlatformMBeanServer() throws BrokerException {
MBeanServer mbeanServer = null;
try {
Class c = Class.forName("java.lang.management.ManagementFactory");
Method m = c.getMethod("getPlatformMBeanServer", (java.lang.Class[]) null);
mbeanServer = (MBeanServer) m.invoke("getPlatformMBeanServer", (java.lang.Object[]) null);
} catch (Exception e) {
throw new BrokerException(rb.getString(rb.W_JMX_GET_PLATFORM_MBEANSERVER_EXCEPTION, e.toString()));
}
return (mbeanServer);
}
use of com.sun.messaging.jmq.jmsserver.util.BrokerException in project openmq by eclipse-ee4j.
the class Agent method startRMIRegistry.
private void startRMIRegistry() throws BrokerException {
Registry registry = null;
boolean registryExists = false;
int port;
if (!startRmiRegistry()) {
return;
}
port = getRmiRegistryPort();
String jmxHostname = Globals.getJMXHostname();
try {
if (jmxHostname != null && !jmxHostname.equals(Globals.HOSTNAME_ALL)) {
registry = LocateRegistry.getRegistry(jmxHostname, port);
} else {
registry = LocateRegistry.getRegistry(port);
}
/*
* Call list() to force a remote call - this confirms if the registry is up and running
*/
registry.list();
registryExists = true;
} catch (RemoteException re) {
/*
* An exception will be caught if there is no registry running at the specified port. Not a problem since we are about
* to create a registry.
*/
}
if (registryExists) {
throw new BrokerException(rb.getString(rb.W_JMX_RMI_REGISTRY_EXISTS, Integer.toString(port)));
}
try {
if (jmxHostname != null && !jmxHostname.equals(Globals.HOSTNAME_ALL)) {
MQRMIServerSocketFactory ssf = new MQRMIServerSocketFactory(jmxHostname, 0, false);
registry = LocateRegistry.createRegistry(port, null, ssf);
} else {
registry = LocateRegistry.createRegistry(port);
}
/*
* Call list() to force a remote call - this confirms if the registry is up and running
*/
registry.list();
logger.log(Logger.INFO, rb.getString(rb.I_JMX_RMI_REGISTRY_STARTED, Integer.toString(port)));
} catch (RemoteException re) {
throw new BrokerException(rb.getString(rb.W_JMX_RMI_REGISTRY_STARTED_EXCEPTION, Integer.toString(port), re.toString()));
}
}
Aggregations