Search in sources :

Example 1 with AutomaticWorkQueueImpl

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;
}
Also used : AutomaticWorkQueue(org.apache.cxf.workqueue.AutomaticWorkQueue) AutomaticWorkQueueImpl(org.apache.cxf.workqueue.AutomaticWorkQueueImpl)

Example 2 with AutomaticWorkQueueImpl

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);
    }
}
Also used : Configuration(org.osgi.service.cm.Configuration) AutomaticWorkQueueImpl(org.apache.cxf.workqueue.AutomaticWorkQueueImpl) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) ConfigurationException(org.osgi.service.cm.ConfigurationException)

Example 3 with AutomaticWorkQueueImpl

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);
    }
}
Also used : AutomaticWorkQueueImpl(org.apache.cxf.workqueue.AutomaticWorkQueueImpl)

Example 4 with AutomaticWorkQueueImpl

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();
}
Also used : AutomaticWorkQueueImpl(org.apache.cxf.workqueue.AutomaticWorkQueueImpl)

Example 5 with AutomaticWorkQueueImpl

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());
}
Also used : Bus(org.apache.cxf.Bus) AutomaticWorkQueueImpl(org.apache.cxf.workqueue.AutomaticWorkQueueImpl) CountDownLatch(java.util.concurrent.CountDownLatch) Endpoint(javax.xml.ws.Endpoint) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) Client(org.apache.cxf.endpoint.Client) WorkQueueManager(org.apache.cxf.workqueue.WorkQueueManager) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Aggregations

AutomaticWorkQueueImpl (org.apache.cxf.workqueue.AutomaticWorkQueueImpl)7 CountDownLatch (java.util.concurrent.CountDownLatch)2 ExecutionException (java.util.concurrent.ExecutionException)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Endpoint (javax.xml.ws.Endpoint)2 Bus (org.apache.cxf.Bus)2 Client (org.apache.cxf.endpoint.Client)2 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)2 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)2 WorkQueueManager (org.apache.cxf.workqueue.WorkQueueManager)2 Test (org.junit.Test)2 TimeoutException (java.util.concurrent.TimeoutException)1 AutomaticWorkQueue (org.apache.cxf.workqueue.AutomaticWorkQueue)1 DDEndpoint (org.jboss.wsf.stack.cxf.metadata.services.DDEndpoint)1 Configuration (org.osgi.service.cm.Configuration)1 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)1 ConfigurationException (org.osgi.service.cm.ConfigurationException)1