use of com.sun.messaging.jmq.jmsservice.JMSServiceReply in project openmq by eclipse-ee4j.
the class DirectXAResource method prepare.
/**
* Ask the resource manager to prepare for a transaction commit of the transaction specified in xid.
*
* @param foreignXid A global transaction identifier.
*
* @return A value indicating the resource manager's vote on the outcome of the transaction. The possible values are:
* XA_RDONLY or XA_OK. If the resource manager wants to roll back the transaction, it should do so by raising an
* appropriate XAException in the prepare method.
*
* @throws XAException If an error has occurred. Possible exception values are: XA_RB*, XAER_RMERR, XAER_RMFAIL,
* XAER_NOTA, XAER_INVAL, or XAER_PROTO.
*/
@Override
public synchronized int prepare(Xid foreignXid) throws XAException {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine(_lgrMID_INF + "DirectXAResource (" + this.hashCode() + ") Prepare " + printXid(foreignXid) + ", connectionId=" + connectionId);
}
// convert to XidImpl
// XidImpl mqxid = new XidImpl(foreignXid);
String methodName = "prepare()";
if (_logFINE) {
// +
_loggerJX.fine(// +
_lgrMID_INF + methodName + ":transactionId=" + this.mTransactionId);
}
// JMS does not do RDONLY transactions
int result = XA_OK;
// JMSServiceReply reply = null;
JMSServiceReply.Status status;
try {
// reply = jmsservice.prepareTransaction(this.connectionId,
jmsservice.prepareTransaction(this.connectionId, this.mTransactionId, foreignXid);
if (_logFINE) {
_loggerJX.fine(_lgrMID_INF + methodName + ":connectionId=" + this.connectionId + ":prepared 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 = "prepareTransaction (XA) on JMSService:" + jmsservice.getJMSServiceID() + " failed for connectionId:" + connectionId + // "and Xid:" + mqxid.toString() +
" due to " + failure_cause;
_loggerOC.severe(exerrmsg);
XAException xae = new XAException(XAException.XAER_RMERR);
xae.initCause(jse);
throw xae;
}
// update the resource state
resourceState = PREPARED;
return result;
}
use of com.sun.messaging.jmq.jmsservice.JMSServiceReply in project openmq by eclipse-ee4j.
the class StompTransactedSession method createSubscriber.
public StompSubscriber createSubscriber(String subid, StompDestination d, String selector, String duraname, boolean nolocal, StompOutputHandler out) throws Exception {
checkSession();
synchronized (this) {
if (subscribers.get(subid) != null) {
throw new StompProtocolException("Subscriber " + subid + " already exist in transacted session " + this);
}
String stompdest = stompconn.getProtocolHandler().toStompFrameDestination(d, false);
Destination dest = ((StompDestinationImpl) d).getDestination();
JMSServiceReply reply = null;
try {
reply = jmsservice.createDestination(connectionId, dest);
} catch (JMSServiceException jmsse) {
JMSServiceReply.Status status = jmsse.getJMSServiceReply().getStatus();
if (status == JMSServiceReply.Status.CONFLICT) {
if (getDEBUG()) {
logger.log(logger.INFO, "Destination " + stompdest + " already exist");
}
} else {
throw jmsse;
}
}
reply = jmsservice.startConnection(connectionId);
reply = jmsservice.addConsumer(connectionId, sessionId, dest, selector, duraname, (duraname != null), false, false, stompconn.getClientID(), nolocal);
long consumerId = reply.getJMQConsumerID();
TransactedSubscriber sub = new TransactedSubscriber(subid, consumerId, duraname, stompdest, out);
subscribers.put(subid, sub);
return sub;
}
}
use of com.sun.messaging.jmq.jmsservice.JMSServiceReply in project openmq by eclipse-ee4j.
the class StompConnectionImpl method connect.
/**
* @return the connection id
*/
@Override
public synchronized String connect(String login, String passcode, String clientid) throws Exception {
this.clientID = clientid;
if (connectionID != null) {
throw new jakarta.jms.IllegalStateException("Unexpected " + StompFrameMessage.Command.CONNECT + ", already connected");
}
JMSServiceReply reply = jmsservice.createConnection(login, passcode);
long connid = reply.getJMQConnectionID();
connectionID = Long.valueOf(connid);
closed = false;
Connection conn = Globals.getConnectionManager().getConnection(new ConnectionUID(connid));
if (conn != null) {
conn.addConnectionClosedListener(this);
} else {
throw new StompProtocolException("No connection");
}
jmsservice.setClientId(connid, clientid, false, /* share */
null);
jmsservice.startConnection(connid);
return connectionID.toString();
}
use of com.sun.messaging.jmq.jmsservice.JMSServiceReply in project openmq by eclipse-ee4j.
the class StompSenderSession method sendStompMessage.
public void sendStompMessage(StompFrameMessage message) throws Exception {
checkSession();
Packet pkt = new Packet();
pkt.setPersistent(jmsservice.DEFAULT_MessageDeliveryMode == MessageDeliveryMode.PERSISTENT);
pkt.setPriority(jmsservice.DEFAULT_MessagePriority.priority());
pkt.setExpiration(jmsservice.DEFAULT_TIME_TO_LIVE);
pkt.setDeliveryTime(jmsservice.DEFAULT_DELIVERY_DELAY);
stompconn.fillRemoteIPAndPort(pkt);
StompDestinationImpl d = fromStompFrameMessage(message, pkt);
String stompdest = d.getStompDestinationString();
try {
jmsservice.createDestination(connectionId, d.getDestination());
} catch (JMSServiceException jmsse) {
JMSServiceReply.Status status = jmsse.getJMSServiceReply().getStatus();
if (status == JMSServiceReply.Status.CONFLICT) {
if (logger.isFineLoggable() || stompconn.getProtocolHandler().getDEBUG()) {
logger.log(logger.INFO, "Destination " + stompdest + " already exist");
}
} else {
throw jmsse;
}
}
synchronized (this) {
Long prodid = producers.get(stompdest);
if (prodid == null) {
JMSServiceReply reply = jmsservice.addProducer(connectionId, sessionId, d.getDestination());
prodid = Long.valueOf(reply.getJMQProducerID());
producers.put(stompdest, prodid);
}
pkt.setProducerID(prodid.longValue());
}
pkt.prepareToSend();
synchronized (this) {
if (isTransacted()) {
pkt.setTransactionID(getTransactionId());
} else {
pkt.setTransactionID(0L);
}
final Packet p = pkt;
jmsservice.sendMessage(connectionId, new JMSPacket() {
@Override
public Packet getPacket() {
return p;
}
});
}
if (logger.isFineLoggable() || stompconn.getProtocolHandler().getDEBUG()) {
logger.log(logger.INFO, "Sent message " + pkt.getSysMessageID());
}
}
use of com.sun.messaging.jmq.jmsservice.JMSServiceReply in project openmq by eclipse-ee4j.
the class StompSubscriberSession method createSubscriber.
public StompSubscriber createSubscriber(StompDestination d, String selector, String duraname, boolean nolocal, StompOutputHandler out) throws Exception {
if (consumerId != 0L) {
throw new IllegalStateException("Subscriber already exists on this Session");
}
this.out = out;
this.stompdest = stompconn.getProtocolHandler().toStompFrameDestination(d, false);
this.duraname = duraname;
Destination dest = ((StompDestinationImpl) d).getDestination();
JMSServiceReply reply = null;
try {
reply = jmsservice.createDestination(connectionId, dest);
} catch (JMSServiceException jmsse) {
JMSServiceReply.Status status = jmsse.getJMSServiceReply().getStatus();
if (status == JMSServiceReply.Status.CONFLICT) {
if (logger.isFineLoggable() || stompconn.getProtocolHandler().getDEBUG()) {
logger.log(logger.INFO, "Destination " + stompdest + " already exist");
}
} else {
throw jmsse;
}
}
reply = jmsservice.startConnection(connectionId);
reply = jmsservice.addConsumer(connectionId, sessionId, dest, selector, duraname, (duraname != null), false, false, stompconn.getClientID(), nolocal);
consumerId = reply.getJMQConsumerID();
if (getDEBUG()) {
logger.log(logger.INFO, "Created " + this);
}
return this;
}
Aggregations