use of jp.ossc.nimbus.service.queue.DefaultQueueService in project nimbus by nimbus-org.
the class ServerConnectionImpl method initAsynchSend.
private void initAsynchSend(ServiceName queueServiceName, ServiceName queueFactoryServiceName, int clientQueueDistributedSize) throws Exception {
if (clientQueueDistributedSize > 0) {
asynchAcceptQueueHandlerContainer = new QueueHandlerContainerService();
asynchAcceptQueueHandlerContainer.create();
if (queueServiceName == null) {
DefaultQueueService acceptQueue = new DefaultQueueService();
acceptQueue.create();
acceptQueue.start();
asynchAcceptQueueHandlerContainer.setQueueService(acceptQueue);
} else {
asynchAcceptQueueHandlerContainer.setQueueServiceName(queueServiceName);
}
asynchAcceptQueueHandlerContainer.setQueueHandlerSize(1);
asynchAcceptQueueHandlerContainer.setQueueHandler(new AsynchAcceptQueueHandler());
asynchAcceptQueueHandlerContainer.setIgnoreNullElement(true);
asynchAcceptQueueHandlerContainer.setWaitTimeout(1000l);
asynchAcceptQueueHandlerContainer.start();
queueSelector = new ClientDistributedQueueSelector();
queueSelector.create();
queueSelector.setDistributedSize(clientQueueDistributedSize);
if (queueFactoryServiceName != null) {
queueSelector.setQueueFactoryServiceName(queueFactoryServiceName);
}
queueSelector.start();
asynchSendQueueHandlerContainer = new DistributedQueueHandlerContainerService();
asynchSendQueueHandlerContainer.create();
asynchSendQueueHandlerContainer.setDistributedQueueSelector(queueSelector);
asynchSendQueueHandlerContainer.setQueueHandler(new SendQueueHandler());
asynchSendQueueHandlerContainer.setIgnoreNullElement(true);
asynchSendQueueHandlerContainer.setWaitTimeout(1000l);
asynchSendQueueHandlerContainer.start();
}
}
use of jp.ossc.nimbus.service.queue.DefaultQueueService in project nimbus by nimbus-org.
the class DistributedClientConnectionImpl method removeSubject.
public void removeSubject(String subject) throws MessageSendException {
if (parallelRequestQueueHandlerContainer == null) {
for (int i = 0, imax = connectionList.size(); i < imax; i++) {
((ClientConnection) connectionList.get(i)).removeSubject(subject);
}
} else {
DefaultQueueService responseQueue = new DefaultQueueService();
try {
responseQueue.create();
responseQueue.start();
} catch (Exception e) {
}
responseQueue.accept();
for (int i = 0, imax = connectionList.size(); i < imax; i++) {
AsynchContext asynchContext = new AsynchContext(new RemoveSubjectParallelRequest((ClientConnection) connectionList.get(i), subject), responseQueue);
parallelRequestQueueHandlerContainer.push(asynchContext);
}
for (int i = 0, imax = connectionList.size(); i < imax; i++) {
AsynchContext asynchContext = (AsynchContext) responseQueue.get();
if (asynchContext == null) {
break;
} else {
try {
asynchContext.checkError();
} catch (MessageSendException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Error e) {
throw e;
} catch (Throwable th) {
// 起きないはず
throw new MessageSendException(th);
}
}
}
}
}
use of jp.ossc.nimbus.service.queue.DefaultQueueService in project nimbus by nimbus-org.
the class DistributedClientConnectionImpl method startReceive.
public void startReceive(long from) throws MessageSendException {
if (parallelRequestQueueHandlerContainer == null) {
for (int i = 0, imax = connectionList.size(); i < imax; i++) {
((ClientConnection) connectionList.get(i)).startReceive(from);
}
} else {
DefaultQueueService responseQueue = new DefaultQueueService();
try {
responseQueue.create();
responseQueue.start();
} catch (Exception e) {
}
responseQueue.accept();
for (int i = 0, imax = connectionList.size(); i < imax; i++) {
AsynchContext asynchContext = new AsynchContext(new StartReceiveParallelRequest((ClientConnection) connectionList.get(i), from), responseQueue);
parallelRequestQueueHandlerContainer.push(asynchContext);
}
for (int i = 0, imax = connectionList.size(); i < imax; i++) {
AsynchContext asynchContext = (AsynchContext) responseQueue.get();
if (asynchContext == null) {
break;
} else {
try {
asynchContext.checkError();
} catch (MessageSendException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Error e) {
throw e;
} catch (Throwable th) {
// 起きないはず
throw new MessageSendException(th);
}
}
}
}
}
use of jp.ossc.nimbus.service.queue.DefaultQueueService in project nimbus by nimbus-org.
the class DistributedClientConnectionImpl method stopReceive.
public void stopReceive() throws MessageSendException {
if (parallelRequestQueueHandlerContainer == null) {
for (int i = 0, imax = connectionList.size(); i < imax; i++) {
((ClientConnection) connectionList.get(i)).stopReceive();
}
} else {
DefaultQueueService responseQueue = new DefaultQueueService();
try {
responseQueue.create();
responseQueue.start();
} catch (Exception e) {
}
responseQueue.accept();
for (int i = 0, imax = connectionList.size(); i < imax; i++) {
AsynchContext asynchContext = new AsynchContext(new StopReceiveParallelRequest((ClientConnection) connectionList.get(i)), responseQueue);
parallelRequestQueueHandlerContainer.push(asynchContext);
}
for (int i = 0, imax = connectionList.size(); i < imax; i++) {
AsynchContext asynchContext = (AsynchContext) responseQueue.get();
if (asynchContext == null) {
break;
} else {
try {
asynchContext.checkError();
} catch (MessageSendException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Error e) {
throw e;
} catch (Throwable th) {
// 起きないはず
throw new MessageSendException(th);
}
}
}
}
}
use of jp.ossc.nimbus.service.queue.DefaultQueueService in project nimbus by nimbus-org.
the class DistributedClientConnectionImpl method addSubject.
public void addSubject(String subject, String[] keys) throws MessageSendException {
if (parallelRequestQueueHandlerContainer == null) {
for (int i = 0, imax = connectionList.size(); i < imax; i++) {
((ClientConnection) connectionList.get(i)).addSubject(subject, keys);
}
} else {
DefaultQueueService responseQueue = new DefaultQueueService();
try {
responseQueue.create();
responseQueue.start();
} catch (Exception e) {
}
responseQueue.accept();
for (int i = 0, imax = connectionList.size(); i < imax; i++) {
AsynchContext asynchContext = new AsynchContext(new AddSubjectParallelRequest((ClientConnection) connectionList.get(i), subject, keys), responseQueue);
parallelRequestQueueHandlerContainer.push(asynchContext);
}
for (int i = 0, imax = connectionList.size(); i < imax; i++) {
AsynchContext asynchContext = (AsynchContext) responseQueue.get();
if (asynchContext == null) {
break;
} else {
try {
asynchContext.checkError();
} catch (MessageSendException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Error e) {
throw e;
} catch (Throwable th) {
// 起きないはず
throw new MessageSendException(th);
}
}
}
}
}
Aggregations