mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@658154 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
90c8ded771
commit
d8b5d5c4cd
|
@ -143,6 +143,7 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
||||||
private boolean watchTopicAdvisories = true;
|
private boolean watchTopicAdvisories = true;
|
||||||
private long warnAboutUnstartedConnectionTimeout = 500L;
|
private long warnAboutUnstartedConnectionTimeout = 500L;
|
||||||
private int sendTimeout =0;
|
private int sendTimeout =0;
|
||||||
|
private boolean sendAcksAsync=true;
|
||||||
|
|
||||||
private final Transport transport;
|
private final Transport transport;
|
||||||
private final IdGenerator clientIdGenerator;
|
private final IdGenerator clientIdGenerator;
|
||||||
|
@ -1533,6 +1534,20 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon
|
||||||
public void setSendTimeout(int sendTimeout) {
|
public void setSendTimeout(int sendTimeout) {
|
||||||
this.sendTimeout = sendTimeout;
|
this.sendTimeout = sendTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the sendAcksAsync
|
||||||
|
*/
|
||||||
|
public boolean isSendAcksAsync() {
|
||||||
|
return sendAcksAsync;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param sendAcksAsync the sendAcksAsync to set
|
||||||
|
*/
|
||||||
|
public void setSendAcksAsync(boolean sendAcksAsync) {
|
||||||
|
this.sendAcksAsync = sendAcksAsync;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -107,6 +107,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
|
||||||
private int producerWindowSize = DEFAULT_PRODUCER_WINDOW_SIZE;
|
private int producerWindowSize = DEFAULT_PRODUCER_WINDOW_SIZE;
|
||||||
private long warnAboutUnstartedConnectionTimeout = 500L;
|
private long warnAboutUnstartedConnectionTimeout = 500L;
|
||||||
private int sendTimeout =0;
|
private int sendTimeout =0;
|
||||||
|
private boolean sendAcksAsync=true;
|
||||||
private TransportListener transportListener;
|
private TransportListener transportListener;
|
||||||
|
|
||||||
// /////////////////////////////////////////////
|
// /////////////////////////////////////////////
|
||||||
|
@ -304,6 +305,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
|
||||||
connection.setProducerWindowSize(getProducerWindowSize());
|
connection.setProducerWindowSize(getProducerWindowSize());
|
||||||
connection.setWarnAboutUnstartedConnectionTimeout(getWarnAboutUnstartedConnectionTimeout());
|
connection.setWarnAboutUnstartedConnectionTimeout(getWarnAboutUnstartedConnectionTimeout());
|
||||||
connection.setSendTimeout(getSendTimeout());
|
connection.setSendTimeout(getSendTimeout());
|
||||||
|
connection.setSendAcksAsync(isSendAcksAsync());
|
||||||
if (transportListener != null) {
|
if (transportListener != null) {
|
||||||
connection.addTransportListener(transportListener);
|
connection.addTransportListener(transportListener);
|
||||||
}
|
}
|
||||||
|
@ -549,6 +551,20 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
|
||||||
public void setSendTimeout(int sendTimeout) {
|
public void setSendTimeout(int sendTimeout) {
|
||||||
this.sendTimeout = sendTimeout;
|
this.sendTimeout = sendTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the sendAcksAsync
|
||||||
|
*/
|
||||||
|
public boolean isSendAcksAsync() {
|
||||||
|
return sendAcksAsync;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param sendAcksAsync the sendAcksAsync to set
|
||||||
|
*/
|
||||||
|
public void setSendAcksAsync(boolean sendAcksAsync) {
|
||||||
|
this.sendAcksAsync = sendAcksAsync;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -645,6 +661,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
|
||||||
props.setProperty("alwaysSyncSend", Boolean.toString(isAlwaysSyncSend()));
|
props.setProperty("alwaysSyncSend", Boolean.toString(isAlwaysSyncSend()));
|
||||||
props.setProperty("producerWindowSize", Integer.toString(getProducerWindowSize()));
|
props.setProperty("producerWindowSize", Integer.toString(getProducerWindowSize()));
|
||||||
props.setProperty("sendTimeout", Integer.toString(getSendTimeout()));
|
props.setProperty("sendTimeout", Integer.toString(getSendTimeout()));
|
||||||
|
props.setProperty("sendAcksAsync",Boolean.toString(isSendAcksAsync()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUseCompression() {
|
public boolean isUseCompression() {
|
||||||
|
|
|
@ -624,7 +624,7 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
|
||||||
executorService.submit(new Runnable() {
|
executorService.submit(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
session.asyncSendPacket(ackToSend);
|
session.sendAck(ackToSend,true);
|
||||||
} catch (JMSException e) {
|
} catch (JMSException e) {
|
||||||
LOG.error(getConsumerId() + " failed to delivered acknowledgements", e);
|
LOG.error(getConsumerId() + " failed to delivered acknowledgements", e);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -757,7 +757,7 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
|
||||||
if (ackCounter >= (info
|
if (ackCounter >= (info
|
||||||
.getCurrentPrefetchSize() * .65)) {
|
.getCurrentPrefetchSize() * .65)) {
|
||||||
MessageAck ack = new MessageAck(md,MessageAck.STANDARD_ACK_TYPE,deliveredMessages.size());
|
MessageAck ack = new MessageAck(md,MessageAck.STANDARD_ACK_TYPE,deliveredMessages.size());
|
||||||
session.asyncSendPacket(ack);
|
session.sendAck(ack);
|
||||||
ackCounter = 0;
|
ackCounter = 0;
|
||||||
deliveredMessages.clear();
|
deliveredMessages.clear();
|
||||||
}
|
}
|
||||||
|
@ -765,7 +765,7 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageAck ack = new MessageAck(md,MessageAck.STANDARD_ACK_TYPE,deliveredMessages.size());
|
MessageAck ack = new MessageAck(md,MessageAck.STANDARD_ACK_TYPE,deliveredMessages.size());
|
||||||
session.asyncSendPacket(ack);
|
session.sendAck(ack);
|
||||||
deliveredMessages.clear();
|
deliveredMessages.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -815,7 +815,7 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
|
||||||
if ((0.5 * info.getPrefetchSize()) <= (deliveredCounter - additionalWindowSize)) {
|
if ((0.5 * info.getPrefetchSize()) <= (deliveredCounter - additionalWindowSize)) {
|
||||||
MessageAck ack = new MessageAck(md, ackType, deliveredCounter);
|
MessageAck ack = new MessageAck(md, ackType, deliveredCounter);
|
||||||
ack.setTransactionId(session.getTransactionContext().getTransactionId());
|
ack.setTransactionId(session.getTransactionContext().getTransactionId());
|
||||||
session.asyncSendPacket(ack);
|
session.sendAck(ack);
|
||||||
additionalWindowSize = deliveredCounter;
|
additionalWindowSize = deliveredCounter;
|
||||||
|
|
||||||
// When using DUPS ok, we do a real ack.
|
// When using DUPS ok, we do a real ack.
|
||||||
|
@ -845,7 +845,7 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
|
||||||
session.doStartTransaction();
|
session.doStartTransaction();
|
||||||
ack.setTransactionId(session.getTransactionContext().getTransactionId());
|
ack.setTransactionId(session.getTransactionContext().getTransactionId());
|
||||||
}
|
}
|
||||||
session.asyncSendPacket(ack);
|
session.sendAck(ack);
|
||||||
|
|
||||||
// Adjust the counters
|
// Adjust the counters
|
||||||
deliveredCounter -= deliveredMessages.size();
|
deliveredCounter -= deliveredMessages.size();
|
||||||
|
@ -859,7 +859,7 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
|
||||||
|
|
||||||
void acknowledge(MessageDispatch md) throws JMSException {
|
void acknowledge(MessageDispatch md) throws JMSException {
|
||||||
MessageAck ack = new MessageAck(md,MessageAck.INDIVIDUAL_ACK_TYPE,1);
|
MessageAck ack = new MessageAck(md,MessageAck.INDIVIDUAL_ACK_TYPE,1);
|
||||||
session.asyncSendPacket(ack);
|
session.sendAck(ack);
|
||||||
synchronized(deliveredMessages){
|
synchronized(deliveredMessages){
|
||||||
deliveredMessages.remove(md);
|
deliveredMessages.remove(md);
|
||||||
}
|
}
|
||||||
|
@ -910,7 +910,7 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
|
||||||
// Acknowledge the last message.
|
// Acknowledge the last message.
|
||||||
|
|
||||||
MessageAck ack = new MessageAck(lastMd, MessageAck.POSION_ACK_TYPE, deliveredMessages.size());
|
MessageAck ack = new MessageAck(lastMd, MessageAck.POSION_ACK_TYPE, deliveredMessages.size());
|
||||||
session.asyncSendPacket(ack);
|
session.sendAck(ack,true);
|
||||||
// ensure we don't filter this as a duplicate
|
// ensure we don't filter this as a duplicate
|
||||||
session.connection.rollbackDuplicate(this, lastMd.getMessage());
|
session.connection.rollbackDuplicate(this, lastMd.getMessage());
|
||||||
// Adjust the window size.
|
// Adjust the window size.
|
||||||
|
@ -919,7 +919,7 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
MessageAck ack = new MessageAck(lastMd, MessageAck.REDELIVERED_ACK_TYPE, deliveredMessages.size());
|
MessageAck ack = new MessageAck(lastMd, MessageAck.REDELIVERED_ACK_TYPE, deliveredMessages.size());
|
||||||
session.asyncSendPacket(ack);
|
session.sendAck(ack,true);
|
||||||
|
|
||||||
// stop the delivery of messages.
|
// stop the delivery of messages.
|
||||||
unconsumedMessages.stop();
|
unconsumedMessages.stop();
|
||||||
|
|
|
@ -1903,5 +1903,17 @@ public class ActiveMQSession implements Session, QueueSession, TopicSession, Sta
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void sendAck(MessageAck ack) throws JMSException {
|
||||||
|
sendAck(ack,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void sendAck(MessageAck ack, boolean lazy) throws JMSException {
|
||||||
|
if (lazy || connection.isSendAcksAsync() || isTransacted()) {
|
||||||
|
asyncSendPacket(ack);
|
||||||
|
} else {
|
||||||
|
syncSendPacket(ack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue