use of org.apache.cxf.workqueue.AutomaticWorkQueueImpl in project cxf by apache.
the class WorkQueueManagerImpl method createAutomaticWorkQueue.
private AutomaticWorkQueue createAutomaticWorkQueue() {
AutomaticWorkQueue q = new AutomaticWorkQueueImpl(DEFAULT_QUEUE_NAME);
addNamedWorkQueue(DEFAULT_QUEUE_NAME, q);
return q;
}
use of org.apache.cxf.workqueue.AutomaticWorkQueueImpl in project cxf by apache.
the class ManagedWorkQueueList method propertyChange.
/*
* On property changes of queue settings we update the config admin service pid of the queue
*/
public void propertyChange(PropertyChangeEvent evt) {
try {
AutomaticWorkQueueImpl queue = (AutomaticWorkQueueImpl) evt.getSource();
ConfigurationAdmin configurationAdmin = configAdminTracker.getService();
if (configurationAdmin != null) {
Configuration selectedConfig = findConfigForQueueName(queue, configurationAdmin);
if (selectedConfig != null) {
Dictionary<String, String> properties = queue.getProperties();
selectedConfig.update(properties);
}
}
} catch (Exception e) {
LOG.log(Level.WARNING, e.getMessage(), e);
}
}
use of org.apache.cxf.workqueue.AutomaticWorkQueueImpl in project cxf by apache.
the class ManagedWorkQueueList method updated.
public void updated(String pid, Dictionary<String, ?> props) throws ConfigurationException {
if (pid == null) {
return;
}
Dictionary<String, String> properties = CastUtils.cast(props);
String queueName = properties.get(AutomaticWorkQueueImpl.PROPERTY_NAME);
if (queues.containsKey(queueName)) {
queues.get(queueName).update(properties);
} else {
AutomaticWorkQueueImpl wq = new AutomaticWorkQueueImpl(queueName);
wq.setShared(true);
wq.update(properties);
wq.addChangeListener(this);
queues.put(pid, wq);
}
}
use of org.apache.cxf.workqueue.AutomaticWorkQueueImpl in project cxf by apache.
the class ManagedWorkQueueList method shutDown.
public void shutDown() {
for (AutomaticWorkQueueImpl wq : queues.values()) {
wq.setShared(false);
wq.shutdown(true);
}
queues.clear();
}
use of org.apache.cxf.workqueue.AutomaticWorkQueueImpl in project cxf by apache.
the class AsyncHTTPConduitTest method testCallAsyncWithFullWorkQueue.
@Test
public void testCallAsyncWithFullWorkQueue() throws Exception {
Bus bus = BusFactory.getThreadDefaultBus();
WorkQueueManager workQueueManager = bus.getExtension(WorkQueueManager.class);
AutomaticWorkQueueImpl automaticWorkQueue1 = (AutomaticWorkQueueImpl) workQueueManager.getAutomaticWorkQueue();
updateAddressPort(g, PORT);
Client client = ClientProxy.getClient(g);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
int asyncExecuteTimeout = 500;
httpClientPolicy.setAsyncExecuteTimeout(asyncExecuteTimeout);
http.setClient(httpClientPolicy);
long repeat = automaticWorkQueue1.getHighWaterMark() + automaticWorkQueue1.getMaxSize() + 1;
CountDownLatch initialThreadsLatch = new CountDownLatch(automaticWorkQueue1.getHighWaterMark());
CountDownLatch doneLatch = new CountDownLatch((int) repeat);
AtomicInteger threadCount = new AtomicInteger();
for (long i = 0; i < repeat; i++) {
g.greetMeLaterAsync(-50, res -> {
try {
int myCount = threadCount.getAndIncrement();
if (myCount < automaticWorkQueue1.getHighWaterMark()) {
// Sleep long enough so that the workqueue will fill up and then
// handleResponseOnWorkqueue will fail for the calls from both
// responseReceived and consumeContent
Thread.sleep(3L * asyncExecuteTimeout);
initialThreadsLatch.countDown();
} else {
Thread.sleep(50);
}
if (!initialThreadsLatch.await(30, TimeUnit.SECONDS)) {
throw new TimeoutException("The initial threads latch timeout exceeded," + " exception in JaxwsClientCallback?");
}
doneLatch.countDown();
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}
doneLatch.await(30, TimeUnit.SECONDS);
assertEquals("All responses should be handled eventually", 0, doneLatch.getCount());
}
Aggregations