use of com.swiftmq.jms.smqp.v400.AsyncMessageDeliveryRequest in project swiftmq-client by iitsoftware.
the class ConnectionConsumerImpl method processRequest.
public void processRequest(AsyncMessageDeliveryRequest request, boolean hasNext) {
if (resetInProgress || deliveryQueue.isCurrentCallInvalid()) {
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, resetInProgress || currentCallInvalid, return");
}
return;
}
if (request.getConnectionId() != myConnection.getConnectionId()) {
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, invalid connectionId (" + request.getConnectionId() + " vs " + myConnection.getConnectionId() + ")");
}
return;
}
try {
if (currentServerSession == null) {
currentServerSession = serverSessionPool.getServerSession();
if (currentServerSession.getSession() instanceof XASessionImpl)
currentSession = ((XASessionImpl) currentServerSession.getSession()).session;
else
currentSession = (SessionImpl) currentServerSession.getSession();
nCurrent = 0;
if (!currentSession.isShadowConsumerCreated())
currentSession.createShadowConsumer(getQueueName());
currentSession.setConnectionConsumer(this);
if (resetInProgress || deliveryQueue.isCurrentCallInvalid()) {
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, resetInProgress || currentCallInvalid, return (2)");
}
return;
}
}
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, " + request.getConnectionId() + " / " + myConnection.getConnectionId());
}
MessageEntry me = request.getMessageEntry();
me.setConnectionId(request.getConnectionId());
currentSession.addMessageChunk(me);
nCurrent++;
if (nCurrent == maxMessages || !hasNext) {
currentServerSession.start();
currentServerSession = null;
currentSession = null;
nCurrent = 0;
}
} catch (Exception e) {
e.printStackTrace();
// TODO: Handle it some way like InvalidateConsumerRequest!!!
}
if (request.isRequiresRestart())
fillCache();
}
use of com.swiftmq.jms.smqp.v400.AsyncMessageDeliveryRequest in project swiftmq-ce by iitsoftware.
the class AsyncMessageProcessor method run.
public void run() {
if (!isValid())
return;
ctx.incMsgsReceived(numberMessages);
deliveryCount += numberMessages;
boolean restart = false;
if (maxBulkSize != -1) {
maxBulkSize -= getCurrentBulkSize();
restart = deliveryCount >= consumerCacheSize - lowWaterMark || maxBulkSize <= 0;
} else
restart = deliveryCount >= consumerCacheSize - lowWaterMark;
MessageEntry[] buffer = getBulkBuffer();
if (isAutoCommit()) {
MessageEntry[] bulk = new MessageEntry[numberMessages];
System.arraycopy(buffer, 0, bulk, 0, numberMessages);
AsyncMessageDeliveryRequest request = new AsyncMessageDeliveryRequest(consumer.getClientDispatchId(), consumer.getClientListenerId(), null, bulk, session.dispatchId, restart, recoveryEpoche);
ctx.connectionOutboundQueue.enqueue(request);
} else {
for (int i = 0; i < numberMessages; i++) {
AsyncMessageDeliveryRequest request = new AsyncMessageDeliveryRequest(consumer.getClientDispatchId(), consumer.getClientListenerId(), buffer[i], null, session.dispatchId, i == numberMessages - 1 && restart, recoveryEpoche);
DeliveryItem item = new DeliveryItem();
item.messageEntry = buffer[i];
item.consumer = consumer;
item.request = request;
ctx.sessionQueue.enqueue(item);
}
}
if (!restart) {
ctx.sessionQueue.enqueue(registerRequest);
} else {
deliveryCount = 0;
maxBulkSize = -1;
started = false;
}
}
use of com.swiftmq.jms.smqp.v400.AsyncMessageDeliveryRequest in project swiftmq-client by iitsoftware.
the class ConnectionConsumerImpl method processRequest.
public void processRequest(AsyncMessageDeliveryRequest request, boolean hasNext) {
if (resetInProgress || deliveryQueue.isCurrentCallInvalid()) {
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, resetInProgress || currentCallInvalid, return");
}
return;
}
if (request.getConnectionId() != myConnection.getConnectionId()) {
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, invalid connectionId (" + request.getConnectionId() + " vs " + myConnection.getConnectionId() + ")");
}
return;
}
try {
if (currentServerSession == null) {
currentServerSession = serverSessionPool.getServerSession();
if (currentServerSession.getSession() instanceof XASessionImpl)
currentSession = ((XASessionImpl) currentServerSession.getSession()).session;
else
currentSession = (SessionImpl) currentServerSession.getSession();
nCurrent = 0;
if (!currentSession.isShadowConsumerCreated())
currentSession.createShadowConsumer(getQueueName());
currentSession.setConnectionConsumer(this);
if (resetInProgress || deliveryQueue.isCurrentCallInvalid()) {
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, resetInProgress || currentCallInvalid, return (2)");
}
return;
}
}
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, " + request.getConnectionId() + " / " + myConnection.getConnectionId());
}
MessageEntry me = request.getMessageEntry();
checkInProgress(me.getMessage(), me.getMessage().getJMSMessageID());
if (resetInProgress || deliveryQueue.isCurrentCallInvalid()) {
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, resetInProgress || currentCallInvalid, return (3)");
}
return;
}
me.setConnectionId(request.getConnectionId());
currentSession.addMessageChunk(me);
nCurrent++;
if (nCurrent == maxMessages || !hasNext) {
currentServerSession.start();
currentServerSession = null;
currentSession = null;
nCurrent = 0;
}
} catch (Exception e) {
e.printStackTrace();
// TODO: Handle it some way like InvalidateConsumerRequest!!!
}
if (request.isRequiresRestart())
fillCache();
}
use of com.swiftmq.jms.smqp.v400.AsyncMessageDeliveryRequest in project swiftmq-client by iitsoftware.
the class ConnectionConsumerImpl method processRequest.
public void processRequest(AsyncMessageDeliveryRequest request, boolean hasNext) {
if (resetInProgress || deliveryQueue.isCurrentCallInvalid()) {
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, resetInProgress || currentCallInvalid, return");
}
return;
}
if (request.getConnectionId() != myConnection.getConnectionId()) {
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, invalid connectionId (" + request.getConnectionId() + " vs " + myConnection.getConnectionId() + ")");
}
return;
}
try {
if (currentServerSession == null) {
currentServerSession = serverSessionPool.getServerSession();
if (currentServerSession.getSession() instanceof XASessionImpl)
currentSession = ((XASessionImpl) currentServerSession.getSession()).session;
else
currentSession = (SessionImpl) currentServerSession.getSession();
nCurrent = 0;
if (!currentSession.isShadowConsumerCreated())
currentSession.createShadowConsumer(getQueueName());
currentSession.setConnectionConsumer(this);
if (resetInProgress || deliveryQueue.isCurrentCallInvalid()) {
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, resetInProgress || currentCallInvalid, return (2)");
}
return;
}
}
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, " + request.getConnectionId() + " / " + myConnection.getConnectionId());
}
MessageEntry me = request.getMessageEntry();
checkInProgress(me.getMessage());
if (resetInProgress || deliveryQueue.isCurrentCallInvalid()) {
if (MessageTracker.enabled) {
MessageTracker.getInstance().track(((AsyncMessageDeliveryRequest) request).getMessageEntry().getMessage(), new String[] { myConnection.toString(), toString() }, "processRequest, resetInProgress || currentCallInvalid, return (3)");
}
return;
}
me.setConnectionId(request.getConnectionId());
currentSession.addMessageChunk(me);
nCurrent++;
if (nCurrent == maxMessages || !hasNext) {
currentServerSession.start();
currentServerSession = null;
currentSession = null;
nCurrent = 0;
}
} catch (Exception e) {
e.printStackTrace();
// TODO: Handle it some way like InvalidateConsumerRequest!!!
}
if (request.isRequiresRestart())
fillCache();
}
use of com.swiftmq.jms.smqp.v400.AsyncMessageDeliveryRequest in project swiftmq-ce by iitsoftware.
the class AsyncMessageProcessor method run.
public void run() {
if (!isValid())
return;
ctx.incMsgsReceived(numberMessages);
deliveryCount += numberMessages;
boolean restart = deliveryCount >= consumerCacheSize;
MessageEntry[] buffer = getBulkBuffer();
if (isAutoCommit()) {
AsyncMessageDeliveryRequest request = new AsyncMessageDeliveryRequest(consumer.getClientDispatchId(), consumer.getClientListenerId(), buffer, numberMessages, session.dispatchId);
request.setRequiresRestart(restart);
request.setRecoveryEpoche(recoveryEpoche);
ctx.connectionOutboundQueue.enqueue(request);
} else {
for (int i = 0; i < numberMessages; i++) {
AsyncMessageDeliveryRequest request = new AsyncMessageDeliveryRequest(consumer.getClientDispatchId(), consumer.getClientListenerId(), buffer[i], session.dispatchId);
request.setRequiresRestart(i == numberMessages - 1 && restart);
request.setRecoveryEpoche(recoveryEpoche);
DeliveryItem item = new DeliveryItem();
item.messageEntry = buffer[i];
item.consumer = consumer;
item.request = request;
ctx.sessionQueue.enqueue(item);
}
}
try {
if (!restart) {
QueuePullTransaction t = consumer.getReadTransaction();
if (t != null && !t.isClosed()) {
try {
t.registerMessageProcessor(this);
} catch (QueueTransactionClosedException e) {
}
}
} else
deliveryCount = 0;
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations