use of com.sun.messaging.jmq.jmsservice.JMSServiceReply in project openmq by eclipse-ee4j.
the class StompTransactedSession method begin.
public void begin(String stomptid) throws Exception {
checkSession();
synchronized (this) {
if (getDEBUG()) {
logger.log(logger.INFO, "Begin transaction " + stomptid + " in [" + this + "]");
}
if (tid != null) {
throw new StompProtocolException("Transaction session has current transaction " + tid);
}
JMSServiceReply reply = jmsservice.startTransaction(connectionId, sessionId, null, 0, TransactionAutoRollback.UNSPECIFIED, 0L);
transactionId = reply.getJMQTransactionID();
setStompTransactionId(stomptid);
}
}
use of com.sun.messaging.jmq.jmsservice.JMSServiceReply in project openmq by eclipse-ee4j.
the class DirectSession method _createAndAddBrowser.
/**
* Create a Browser with the jmsservice and return a consumerId. Used by the methods implementing jakarta.jms.Session,
* jakarta.jms.QueueSession, and jakarta.jms.TopicSession
*
* @param methodName The JMS API method that was called.
* @param destination The JMS Destination object identifying the destination on which the browser is to be created.
* @param selector The JMS Message selector to be used.
*
* @return The DirectQueueBrowser object to be returned by the JMS API method.
*
* @throws JMSException if any JMS error occurred.
*/
private DirectQueueBrowser _createAndAddBrowser(String methodName, Queue destination, String selector) throws JMSException {
JMSServiceReply reply;
long consumerId = 0L;
DirectQueueBrowser browser = null;
com.sun.messaging.jmq.jmsservice.Destination jmsservice_dest;
if (_logFINE) {
_loggerJS.fine(_lgrMID_INF + "sessionId=" + sessionId + ":" + methodName + ":Destination=" + destination + ":selector=" + selector);
}
this._checkIfClosed(methodName);
jmsservice_dest = this._checkDestinationForConsumer(destination);
try {
reply = jmsservice.addBrowser(connectionId, sessionId, jmsservice_dest, selector);
try {
// Must get a consumerId from the addBrowser method
consumerId = reply.getJMQConsumerID();
} catch (NoSuchFieldException nsfe) {
String exerrmsg = _lgrMID_EXC + methodName + "JMSServiceException:Missing JMQConsumerID";
JMSException jmse = new JMSException(exerrmsg);
jmse.initCause(nsfe);
_loggerJS.severe(exerrmsg);
throw jmse;
}
browser = new DirectQueueBrowser(this, jmsservice, consumerId, destination, jmsservice_dest, selector);
} catch (JMSServiceException jse) {
JMSServiceReply.Status status = jse.getJMSServiceReply().getStatus();
String failure_cause;
JMSException jmsse = null;
String exerrmsg = "createBrowser on JMSService:" + jmsservice.getJMSServiceID() + " failed for connectionId:" + connectionId + " and sessionId:" + sessionId + " due to ";
switch(status) {
case FORBIDDEN:
failure_cause = "client forbidden to browse messages from this destination.";
exerrmsg = exerrmsg + failure_cause;
jmsse = new JMSSecurityException(exerrmsg, jse.getJMSServiceReply().getErrorCode());
break;
case NOT_FOUND:
failure_cause = "destination not found and cannot be auto-created.";
break;
case CONFLICT:
failure_cause = "destination limit for number of consumers exceeded.";
break;
case BAD_REQUEST:
failure_cause = "invalid selector=" + selector;
exerrmsg = exerrmsg + failure_cause;
jmsse = new InvalidSelectorException(exerrmsg);
break;
default:
failure_cause = "unkown JMSService server error.";
}
_loggerJS.severe(exerrmsg);
if (jmsse == null) {
exerrmsg = exerrmsg + failure_cause;
jmsse = new JMSException(exerrmsg);
}
jmsse.initCause(jse);
throw jmsse;
}
this.addBrowser(browser);
return browser;
}
use of com.sun.messaging.jmq.jmsservice.JMSServiceReply in project openmq by eclipse-ee4j.
the class DirectSession method _createProducerId.
/**
* Create a producer with the jmsservice and return a producerId.
* <p>
* Used by createAndAddProducer in DirectSession as well as _createAndAddProducerId method in DirectProducer when a JMS
* message is produced using a DirectProducer that was created using an unspeificed JMS Destination (i.e. null)
*
* @param destination The com.sun.messaging.jmsservice.Destination object identifying the destination on which the
* producer is to be created.
*
* @return The producerId to be used by the DirectProducer object that is returned by the JMS API method
*
* @throws JMSException if any JMS server error occurred
*/
protected long _createProducerId(com.sun.messaging.jmq.jmsservice.Destination destination) throws JMSException {
JMSServiceReply reply;
long producerId = 0L;
try {
reply = jmsservice.addProducer(this.connectionId, this.sessionId, destination);
try {
producerId = reply.getJMQProducerID();
} catch (NoSuchFieldException nsfe) {
String exerrmsg = _lgrMID_EXC + "JMSServiceException:Missing JMQProducerID";
JMSException jmse = new JMSException(exerrmsg);
jmse.initCause(nsfe);
_loggerJS.severe(exerrmsg);
throw jmse;
}
} catch (JMSServiceException jse) {
JMSServiceReply.Status status = jse.getJMSServiceReply().getStatus();
String failure_cause;
String exerrmsg = "createProducer on JMSService:" + jmsservice.getJMSServiceID() + " failed for connectionId:" + connectionId + " and sessionId:" + sessionId + " due to ";
JMSException jmsse = null;
switch(status) {
case FORBIDDEN:
failure_cause = "client forbidden to send messages to this destination.";
exerrmsg = exerrmsg + failure_cause;
jmsse = new JMSSecurityException(exerrmsg, jse.getJMSServiceReply().getErrorCode());
break;
case NOT_FOUND:
failure_cause = "destination not found and cannot be auto-created.";
break;
case CONFLICT:
failure_cause = "destination limit for number of producers exceeded.";
break;
default:
failure_cause = "unkown JMSService server error.";
}
_loggerJS.severe(exerrmsg);
if (jmsse == null) {
jmsse = new JMSException(exerrmsg + failure_cause);
}
jmsse.initCause(jse);
throw jmsse;
}
return producerId;
}
use of com.sun.messaging.jmq.jmsservice.JMSServiceReply in project openmq by eclipse-ee4j.
the class DirectXAResource method sendEndToBroker.
/**
* Notify the broker than end() has been called
*/
public synchronized void sendEndToBroker(Xid foreignXid, int flags) throws XAException {
// convert to XidImpl
// XidImpl mqxid = new XidImpl(foreignXid);
String methodName = "endToBroker()";
if (_logFINE) {
// +
_loggerJX.fine(// +
_lgrMID_INF + methodName + ":flags=" + flags + ":transactionId=" + this.mTransactionId);
}
// JMSServiceReply reply = null;
JMSServiceReply.Status status;
try {
// reply = jmsservice.endTransaction(this.connectionId,
jmsservice.endTransaction(this.connectionId, this.mTransactionId, foreignXid, flags);
if (_logFINE) {
_loggerJX.fine(_lgrMID_INF + methodName + ":connectionId=" + this.connectionId + ":ended transactionId=" + this.mTransactionId);
}
} catch (JMSServiceException jse) {
status = jse.getJMSServiceReply().getStatus();
String failure_cause = getFailureCauseAsString(status, jse);
// XXX:tharakan:This message should be in the JMSServiceException
String exerrmsg = "endTransaction (XA) on JMSService:" + jmsservice.getJMSServiceID() + " failed for connectionId:" + connectionId + // "and Xid:" + mqxid.toString() +
" and flags=" + flags + " due to " + failure_cause;
_loggerOC.severe(exerrmsg);
XAException xae = new XAException(XAException.XAER_RMERR);
xae.initCause(jse);
throw xae;
}
}
use of com.sun.messaging.jmq.jmsservice.JMSServiceReply in project openmq by eclipse-ee4j.
the class DirectConnectionFactory method _createConnectionId.
// ///////////////////////////////////////////////////////////////////////
// end jakarta.jms.TopicConnectionFactory
// ///////////////////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////////////////
// MQ methods
// ///////////////////////////////////////////////////////////////////////
/**
* Create a connection with the jmsservice and return a connectionId. Used by the methods implementing
* jakarta.jms.Connection, jakarta.jms.QueueConnection, and jakarta.jms.TopicConnection
*
* @param username The username that should be used to authenticate the creation of the connection with the jmsservice
* @param password The password that should be used to authenticate the creation of the connection with the jmsservice
*
* @return The connectionId to be used by the DirectConnection object that is returned by the JMS API method
*
* @throws JMSSecurityException if the specified user identity does not authenticate successfully with the JMS server
* @throws JMSException if any JMS server error occurred
*/
private long _createConnectionId(String username, String password) throws JMSException {
JMSServiceReply reply;
long connectionId = 0L;
if (this.jmsservice == null) {
if (this.ra != null) {
this.jmsservice = this.ra._getJMSService();
}
if (this.jmsservice == null) {
// Ultimate fallback :)
this.jmsservice = ResourceAdapter._getRAJMSService();
}
}
assert (this.jmsservice != null);
try {
reply = jmsservice.createConnection(username, password);
try {
connectionId = reply.getJMQConnectionID();
} catch (NoSuchFieldException nsfe) {
String exerrmsg = _lgrMID_EXC + "JMSServiceException:Missing JMQConnectionID";
JMSException jmse = new JMSException(exerrmsg);
jmse.initCause(nsfe);
_loggerJF.severe(exerrmsg);
throw jmse;
}
} catch (JMSServiceException jse) {
JMSServiceReply.Status status = jse.getJMSServiceReply().getStatus();
JMSException jmsse;
String failure_cause;
boolean security_exception = true;
switch(status) {
case INVALID_LOGIN:
failure_cause = "authentication failure.";
break;
case FORBIDDEN:
failure_cause = "authorization failure.";
break;
default:
failure_cause = "unkown JMSService server error.";
security_exception = false;
}
String exerrmsg = "createConnection on JMSService:" + jmsservice.getJMSServiceID() + " failed for username:" + username + " due to " + failure_cause;
_loggerJF.severe(exerrmsg);
jmsse = (security_exception ? new JMSSecurityException(exerrmsg, jse.getJMSServiceReply().getErrorCode()) : new JMSException(exerrmsg, jse.getJMSServiceReply().getErrorCode()));
jmsse.initCause(jse);
throw jmsse;
}
return connectionId;
}
Aggregations