use of com.sun.messaging.jmq.jmsservice.JMSAck in project openmq by eclipse-ee4j.
the class DirectMDBSession method _deliverMessage.
/**
* Deliver a message from this DirectSession - only one thread can do this at a time.
*/
@Override
protected synchronized JMSAck _deliverMessage(jakarta.jms.MessageListener msgListener, JMSPacket jmsPacket, long consumerId) throws ConsumerClosedNoDeliveryException {
JMSAck jmsAck = null;
if (this.enableThreadCheck) {
// Relies on the *same* thread being used to deliver all messages
// while this sesion is alive
long tId = Thread.currentThread().getId();
if (this.deliverThreadId == 0L) {
// first time
this.deliverThreadId = tId;
} else {
if (this.deliverThreadId != tId) {
throw new RuntimeException("Invalid to call deliver from two different threads!");
}
}
}
jakarta.jms.Message jmsMsg = null;
if (msgListener == null) {
throw new RuntimeException("DirectConsumer:MessageListener not set!");
}
if (jmsPacket == null) {
throw new RuntimeException("DirectConsumer:JMSPacket is null!");
}
try {
jmsMsg = DirectPacket.constructMessage(jmsPacket, consumerId, this, this.jmsservice, false);
} catch (Exception e) {
}
if (jmsMsg == null) {
throw new RuntimeException("DirectConsumer:JMS Message in Packet is null!");
}
try {
this.inDeliver = true;
msgListener.onMessage(jmsMsg);
// this.ds._deliverMessage(this.msgListener, jmsMsg);
this.inDeliver = false;
if (this.ackMode != SessionAckMode.CLIENT_ACKNOWLEDGE) {
jmsAck = new DirectAck(this.connectionId, this.sessionId, consumerId, ((DirectPacket) jmsMsg).getReceivedSysMessageID(), JMSService.MessageAckType.ACKNOWLEDGE);
}
} catch (Exception e) {
System.out.println("DirectConsumer:Caught Exception delivering message" + e.getMessage());
}
return jmsAck;
}
use of com.sun.messaging.jmq.jmsservice.JMSAck in project openmq by eclipse-ee4j.
the class StompSubscriberSession method deliver.
@Override
public JMSAck deliver(JMSPacket msgpkt) throws ConsumerClosedNoDeliveryException {
if (closing || closed || stompconn.isClosed()) {
throw new ConsumerClosedNoDeliveryException("Subscriber " + this + " is closed");
}
try {
final boolean needAck = (ackMode != SessionAckMode.AUTO_ACKNOWLEDGE);
StompFrameMessage msg = toStompFrameMessage(subid, stompdest, msgpkt.getPacket(), needAck);
if (stompconn.getProtocolHandler().getDEBUG()) {
logger.log(logger.INFO, " SEND message " + msg + " for " + toString());
}
if (ackMode != SessionAckMode.CLIENT_ACKNOWLEDGE) {
out.sendToClient(msg, stompconn.getProtocolHandler(), null);
return new Ack(msgpkt.getPacket(), MessageAckType.ACKNOWLEDGE);
} else {
unackedMessages.add(msgpkt.getPacket().getSysMessageID());
out.sendToClient(msg, stompconn.getProtocolHandler(), null);
}
} catch (Exception e) {
logger.logStack(logger.WARNING, e.getMessage(), e);
}
return null;
}
use of com.sun.messaging.jmq.jmsservice.JMSAck in project openmq by eclipse-ee4j.
the class DirectSession method _deliverMessage.
/**
* Deliver a message from this DirectSession - only one thread can do this at a time.
*/
protected synchronized JMSAck _deliverMessage(jakarta.jms.MessageListener msgListener, JMSPacket jmsPacket, long consumerId) throws ConsumerClosedNoDeliveryException {
JMSAck jmsAck = null;
SysMessageID messageID = null;
if (this.enableThreadCheck) {
// Relies on the *same* thread being used to deliver all messages
// while this sesion is alive
long tId = Thread.currentThread().getId();
if (this.deliverThreadId == 0L) {
// first time
this.deliverThreadId = tId;
} else {
if (this.deliverThreadId != tId) {
throw new RuntimeException("Invalid to call deliver from two different threads!");
}
}
}
jakarta.jms.Message jmsMsg = null;
if (msgListener == null) {
throw new RuntimeException("DirectConsumer:MessageListener not set!");
}
if (jmsPacket == null) {
throw new RuntimeException("DirectConsumer:JMSPacket is null!");
}
try {
jmsMsg = DirectPacket.constructMessage(jmsPacket, consumerId, this, this.jmsservice, false);
} catch (Exception e) {
}
if (jmsMsg == null) {
throw new RuntimeException("DirectConsumer:JMS Message in Packet is null!");
}
try {
this.inDeliver = true;
msgListener.onMessage(jmsMsg);
// this.ds._deliverMessage(this.msgListener, jmsMsg);
this.inDeliver = false;
messageID = ((DirectPacket) jmsMsg).getReceivedSysMessageID();
if (this.ackMode != SessionAckMode.CLIENT_ACKNOWLEDGE) {
/*
* if (this.dc.isManaged() && this.dc.isEnlisted()){ xaTxnId = this.dc._getXAResource()._getTransactionId(); } else {
* xaTxnId = this._getTransactionId(); }
*/
jmsAck = new DirectAck(this.connectionId, this.sessionId, consumerId, messageID, JMSService.MessageAckType.ACKNOWLEDGE);
} else {
// Do not need to recover an MDB Session
if (!this._isMDBSession()) {
// Insert message's SysMessageID and consumerId for recover
// for non-MDB Session
unackedMessageIDs.add(messageID);
unackedConsumerIDs.add(consumerId);
}
}
} catch (ConsumerClosedNoDeliveryException e) {
throw e;
} catch (Exception e) {
System.out.println("DirectConsumer:Caught Exception delivering message" + e.getMessage());
// Re-attempt redelivery semantics here
// Ack UNDELIVERABLE or DEAD
}
return jmsAck;
}
Aggregations