use of jp.ossc.nimbus.service.queue.BeanFlowAsynchContext in project nimbus by nimbus-org.
the class BeanFlowMonitorImpl method cancel.
public void cancel() {
if (monitorSet != null) {
Iterator monitors = monitorSet.iterator();
while (monitors.hasNext()) {
BeanFlowMonitor monitor = (BeanFlowMonitor) monitors.next();
monitor.cancel();
}
}
if (asynchContextSet != null) {
Iterator contexts = asynchContextSet.iterator();
while (contexts.hasNext()) {
BeanFlowAsynchContext context = (BeanFlowAsynchContext) contexts.next();
context.cancel();
contexts.remove();
}
}
}
use of jp.ossc.nimbus.service.queue.BeanFlowAsynchContext in project nimbus by nimbus-org.
the class BeanFlowInvokerAccessImpl2 method getAsynchReply.
public Object getAsynchReply(Object context, BeanFlowMonitor monitor, long timeout, boolean isCancel) throws BeanFlowAsynchTimeoutException, Exception {
BeanFlowAsynchContext asynchContext = (BeanFlowAsynchContext) context;
Queue queue = asynchContext.getResponseQueue();
if (queue == null) {
return null;
}
asynchContext = (BeanFlowAsynchContext) queue.get(timeout);
if (asynchContext == null) {
if (isCancel) {
if (monitor != null) {
monitor.cancel();
monitor.stop();
}
BeanFlowInvoker invoker = ((BeanFlowAsynchContext) context).getBeanFlowInvoker();
if (invoker != null) {
invoker.end();
}
}
throw new BeanFlowAsynchTimeoutException(flowName);
}
if (asynchContext != null) {
BeanFlowMonitor subMonitor = asynchContext.getBeanFlowMonitor();
if (subMonitor != null) {
((BeanFlowMonitorImpl) subMonitor).removeAsynchContext((BeanFlowAsynchContext) context);
if (monitor != null) {
((BeanFlowMonitorImpl) monitor).removeBeanFlowMonitor(subMonitor);
}
}
}
BeanFlowInvoker invoker = ((BeanFlowAsynchContext) context).getBeanFlowInvoker();
if (invoker != null) {
invoker.end();
}
try {
asynchContext.checkError();
} catch (Throwable th) {
if (th instanceof Exception) {
throw (Exception) th;
} else {
throw (Error) th;
}
}
return asynchContext.getOutput();
}
use of jp.ossc.nimbus.service.queue.BeanFlowAsynchContext in project nimbus by nimbus-org.
the class BeanFlowInvokerAccessImpl2 method invokeAsynchFlow.
public Object invokeAsynchFlow(Object obj, BeanFlowMonitor monitor, BeanFlowAsynchInvokeCallback callback, int maxAsynchWait) throws Exception {
QueueHandlerContainer qhc = factoryCallBack.getAsynchInvokeQueueHandlerContainer();
if (qhc == null) {
throw new UnsupportedOperationException();
}
if (maxAsynchWait > 0 && qhc.size() > maxAsynchWait) {
throw new UnavailableFlowException(flowName);
}
BeanFlowInvoker invoker = (BeanFlowInvoker) factoryCallBack.createFlow(flowName);
BeanFlowMonitor newMonitor = createMonitor();
if (callback != null) {
((BeanFlowMonitorImpl) monitor).addBeanFlowMonitor(newMonitor);
}
BeanFlowAsynchContext context = callback == null ? new BeanFlowAsynchContext(invoker, obj, newMonitor) : new BeanFlowAsynchContext(invoker, obj, newMonitor, callback);
if (factoryCallBack.getThreadContext() != null) {
context.putThreadContextAll(factoryCallBack.getThreadContext());
}
((BeanFlowMonitorImpl) newMonitor).addAsynchContext(context);
qhc.push(context);
return context;
}
use of jp.ossc.nimbus.service.queue.BeanFlowAsynchContext in project nimbus by nimbus-org.
the class BeanFlowInvokerAccessImpl2 method invokeAsynchFlow.
public Object invokeAsynchFlow(Object obj, BeanFlowMonitor monitor, boolean isReply, int maxAsynchWait) throws Exception {
QueueHandlerContainer qhc = factoryCallBack.getAsynchInvokeQueueHandlerContainer();
if (qhc == null) {
throw new UnsupportedOperationException();
}
if (maxAsynchWait > 0 && qhc.size() > maxAsynchWait) {
throw new UnavailableFlowException(flowName);
}
BeanFlowInvoker invoker = (BeanFlowInvoker) factoryCallBack.createFlow(flowName);
BeanFlowAsynchContext context = null;
BeanFlowMonitor newMonitor = createMonitor();
if (isReply) {
((BeanFlowMonitorImpl) monitor).addBeanFlowMonitor(newMonitor);
final DefaultQueueService replyQueue = new DefaultQueueService();
replyQueue.create();
replyQueue.start();
context = new BeanFlowAsynchContext(invoker, obj, newMonitor, replyQueue);
} else {
context = new BeanFlowAsynchContext(invoker, obj, newMonitor);
}
if (factoryCallBack.getThreadContext() != null) {
context.putThreadContextAll(factoryCallBack.getThreadContext());
}
((BeanFlowMonitorImpl) newMonitor).addAsynchContext(context);
qhc.push(context);
return context;
}
Aggregations