use of com.swiftmq.tools.requestreply.Reply in project swiftmq-client by iitsoftware.
the class Connector method visit.
public void visit(PODataAvailable po) {
if (debug)
System.out.println(toString() + ", visit, po=" + po + " ...");
try {
if (po.getIoException() != null)
throw po.getIoException();
Dumpable obj = po.getDumpable();
if (debug)
System.out.println(toString() + ", dataAvailable, obj=" + obj);
if (!recreateStarted) {
if (obj.getDumpId() == SMQPFactory.DID_BULK_REQ) {
SMQPBulkRequest bulkRequest = (SMQPBulkRequest) obj;
for (int i = 0; i < bulkRequest.len; i++) {
Dumpable dumpable = (Dumpable) bulkRequest.dumpables[i];
if (dumpable.getDumpId() != SMQPFactory.DID_KEEPALIVE_REQ)
setReply(dumpable);
}
} else
setReply(obj);
current = null;
} else if (obj.getDumpId() == SMQPFactory.DID_BULK_REQ) {
SMQPBulkRequest bulkRequest = (SMQPBulkRequest) obj;
for (int i = 0; i < bulkRequest.len; i++) {
Dumpable dumpable = (Dumpable) bulkRequest.dumpables[i];
if (dumpable.getDumpId() != SMQPFactory.DID_KEEPALIVE_REQ) {
currentRecreatePO.getRecreatable().setRecreateReply((Reply) dumpable);
currentRecreatePO.setSuccess(true);
if (currentRecreatePO.getSemaphore() != null)
currentRecreatePO.getSemaphore().notifySingleWaiter();
}
}
} else {
currentRecreatePO.getRecreatable().setRecreateReply((Reply) obj);
currentRecreatePO.setSuccess(true);
if (currentRecreatePO.getSemaphore() != null)
currentRecreatePO.getSemaphore().notifySingleWaiter();
}
currentRecreatePO = null;
requestTime = -1;
} catch (Exception e) {
if (debug)
System.out.println(toString() + ", visit, po=" + po + ", exception=" + e + ", recreateStarted=" + recreateStarted);
if (currentRecreatePO != null) {
currentRecreatePO.setSuccess(false);
currentRecreatePO.setException(e.toString());
if (currentRecreatePO.getSemaphore() != null)
currentRecreatePO.getSemaphore().notifySingleWaiter();
currentRecreatePO = null;
recreateStarted = false;
if (debug)
System.out.println(toString() + ", set recreateStarted to " + recreateStarted);
}
reconnector.invalidateConnection();
connection = null;
reconnectInProgress = false;
currentRecreatePO = null;
requestTime = -1;
if (debug)
System.out.println(toString() + ", ((e instanceof JMSSecurityException) || (e instanceof InvalidVersionException))?" + ((e instanceof JMSSecurityException) || (e instanceof InvalidVersionException)));
if ((e instanceof JMSSecurityException) || (e instanceof InvalidVersionException)) {
if (sem != null)
sem.notifySingleWaiter();
} else {
if (debug)
System.out.println(toString() + ", e is instanceof " + e.getClass().getName());
dispatch(new POReconnect(sem, recreatableConnection, true));
}
}
if (debug)
System.out.println(toString() + ", visit, po=" + po + " done");
}
use of com.swiftmq.tools.requestreply.Reply in project swiftmq-client by iitsoftware.
the class Connector method visit.
public void visit(PODataAvailable po) {
if (debug)
System.out.println(toString() + ", visit, po=" + po + " ...");
DataInput in = po.getIn();
try {
Dumpable obj = Dumpalizer.construct(in, dumpableFactory);
if (debug)
System.out.println(toString() + ", dataAvailable, obj=" + obj);
if (obj == null || obj.getDumpId() == SMQPFactory.DID_KEEPALIVE_REQ) {
return;
}
if (!recreateStarted) {
if (obj.getDumpId() == SMQPFactory.DID_BULK_REQ) {
SMQPBulkRequest bulkRequest = (SMQPBulkRequest) obj;
for (int i = 0; i < bulkRequest.len; i++) {
Dumpable dumpable = (Dumpable) bulkRequest.dumpables[i];
if (dumpable.getDumpId() != SMQPFactory.DID_KEEPALIVE_REQ)
setReply(dumpable);
}
} else
setReply(obj);
current = null;
} else if (obj.getDumpId() == SMQPFactory.DID_BULK_REQ) {
SMQPBulkRequest bulkRequest = (SMQPBulkRequest) obj;
for (int i = 0; i < bulkRequest.len; i++) {
Dumpable dumpable = (Dumpable) bulkRequest.dumpables[i];
if (dumpable.getDumpId() != SMQPFactory.DID_KEEPALIVE_REQ) {
currentRecreatePO.getRecreatable().setRecreateReply((Reply) dumpable);
currentRecreatePO.setSuccess(true);
if (currentRecreatePO.getSemaphore() != null)
currentRecreatePO.getSemaphore().notifySingleWaiter();
}
}
} else {
currentRecreatePO.getRecreatable().setRecreateReply((Reply) obj);
currentRecreatePO.setSuccess(true);
if (currentRecreatePO.getSemaphore() != null)
currentRecreatePO.getSemaphore().notifySingleWaiter();
}
currentRecreatePO = null;
requestTime = -1;
} catch (Exception e) {
if (debug)
System.out.println(toString() + ", visit, po=" + po + ", exception=" + e);
if (currentRecreatePO != null) {
currentRecreatePO.setSuccess(false);
currentRecreatePO.setException(e.toString());
if (currentRecreatePO.getSemaphore() != null)
currentRecreatePO.getSemaphore().notifySingleWaiter();
currentRecreatePO = null;
}
reconnector.invalidateConnection();
connection = null;
reconnectInProgress = false;
currentRecreatePO = null;
requestTime = -1;
if (debug)
System.out.println(toString() + ", ((e instanceof JMSSecurityException) || (e instanceof InvalidVersionException))?" + ((e instanceof JMSSecurityException) || (e instanceof InvalidVersionException)));
if ((e instanceof JMSSecurityException) || (e instanceof InvalidVersionException)) {
if (sem != null)
sem.notifySingleWaiter();
} else {
if (debug)
System.out.println(toString() + ", e is instanceof " + e.getClass().getName());
dispatch(new POReconnect(sem, recreatableConnection, true));
}
}
if (debug)
System.out.println(toString() + ", visit, po=" + po + " done");
}
use of com.swiftmq.tools.requestreply.Reply in project swiftmq-client by iitsoftware.
the class TopicConnectionConsumerImpl method createSubscriber.
void createSubscriber(TopicImpl topic, String messageSelector) throws JMSException {
this.topic = topic;
this.messageSelector = messageSelector;
isDurable = false;
Reply reply = null;
try {
reply = requestRegistry.request(new CreateSubscriberRequest(this, dispatchId, topic, messageSelector, false, false));
} catch (Exception e) {
throw ExceptionConverter.convert(e);
}
if (reply.isOk()) {
queueName = ((CreateSubscriberReply) reply).getTmpQueueName();
} else {
throw ExceptionConverter.convert(reply.getException());
}
fillCache();
}
use of com.swiftmq.tools.requestreply.Reply in project swiftmq-client by iitsoftware.
the class QueueConnectionConsumerImpl method createConsumer.
void createConsumer(QueueImpl queue, String messageSelector) throws JMSException {
if (queue == null)
throw new NullPointerException("createConsumer, queue is null!");
queueName = queue.getQueueName();
this.queue = queue;
this.messageSelector = messageSelector;
Reply reply = null;
try {
reply = requestRegistry.request(new CreateConsumerRequest(this, dispatchId, (QueueImpl) queue, messageSelector));
} catch (Exception e) {
throw ExceptionConverter.convert(e);
}
if (!reply.isOk())
throw ExceptionConverter.convert(reply.getException());
fillCache();
}
use of com.swiftmq.tools.requestreply.Reply in project swiftmq-client by iitsoftware.
the class TopicConnectionConsumerImpl method createDurableSubscriber.
void createDurableSubscriber(TopicImpl topic, String messageSelector, String durableName) throws JMSException {
this.topic = topic;
this.messageSelector = messageSelector;
this.durableName = durableName;
isDurable = true;
try {
SwiftUtilities.verifyDurableName(durableName);
} catch (Exception e) {
throw new JMSException(e.getMessage());
}
Reply reply = null;
try {
reply = requestRegistry.request(new CreateDurableRequest(this, dispatchId, topic, messageSelector, false, durableName));
} catch (Exception e) {
throw ExceptionConverter.convert(e);
}
if (reply.isOk()) {
queueName = ((CreateDurableReply) reply).getQueueName();
} else {
throw ExceptionConverter.convert(reply.getException());
}
fillCache();
}
Aggregations