Search in sources :

Example 1 with HelloWorldServiceRuntimeCorrelationIDStaticPrefix

use of org.apache.cxf.hello_world_jms.HelloWorldServiceRuntimeCorrelationIDStaticPrefix in project cxf by apache.

the class JMSSharedQueueTest method testTwoWayQueueRuntimeCorrelationIDStaticPrefix.

/*
     * This tests a use case where there is a shared request and reply queues between
     * two servers (Eng and Sales). However each server has a design time provided selector
     * which allows them to share the same queue and do not consume the other's
     * messages.
     *
     * The clients to these two servers use the same request and reply queues.
     * An Eng client uses a design time selector prefix to form request message
     * correlationID and to form a reply consumer that filters only reply
     * messages originated from the Eng server. To differentiate between
     * one Eng client instance from another this suffix is supplemented by
     * a runtime value of ConduitId which has 1-1 relation to a client instance
     * This guarantees that an Eng client instance will only consume its own reply
     * messages.
     *
     * In case of a single client instance being shared among multiple threads
     * the third portion of the request message correlationID,
     * an atomic rolling message counter, ensures that each message gets a unique ID
     *
     * So the model is:
     *
     * Many concurrent Sales clients to a single request and reply queues (Q1, Q2)
     * to a single Sales server
     * Many concurrent Eng clients to a single request and reply queues (Q1, Q2)
     * to a single Eng server
     */
@Test
public void testTwoWayQueueRuntimeCorrelationIDStaticPrefix() throws Throwable {
    QName serviceName = new QName(SERVICE_NS, "HelloWorldServiceRuntimeCorrelationIDStaticPrefix");
    QName portNameEng = new QName(SERVICE_NS, "HelloWorldPortRuntimeCorrelationIDStaticPrefixEng");
    QName portNameSales = new QName(SERVICE_NS, "HelloWorldPortRuntimeCorrelationIDStaticPrefixSales");
    URL wsdl = getWSDLURL(WSDL);
    HelloWorldServiceRuntimeCorrelationIDStaticPrefix service = new HelloWorldServiceRuntimeCorrelationIDStaticPrefix(wsdl, serviceName);
    HelloWorldPortType portEng = markForClose(service.getPort(portNameEng, HelloWorldPortType.class, cff));
    HelloWorldPortType portSales = markForClose(service.getPort(portNameSales, HelloWorldPortType.class, cff));
    Collection<ClientRunnable> clients = new ArrayList<>();
    for (int i = 0; i < 10; ++i) {
        clients.add(new ClientRunnable(portEng, "com.mycompany.eng:"));
        clients.add(new ClientRunnable(portSales, "com.mycompany.sales:"));
    }
    executeAsync(clients);
}
Also used : HelloWorldServiceRuntimeCorrelationIDStaticPrefix(org.apache.cxf.hello_world_jms.HelloWorldServiceRuntimeCorrelationIDStaticPrefix) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) HelloWorldPortType(org.apache.cxf.hello_world_jms.HelloWorldPortType) URL(java.net.URL) Test(org.junit.Test) AbstractVmJMSTest(org.apache.cxf.systest.jms.AbstractVmJMSTest)

Aggregations

URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 HelloWorldPortType (org.apache.cxf.hello_world_jms.HelloWorldPortType)1 HelloWorldServiceRuntimeCorrelationIDStaticPrefix (org.apache.cxf.hello_world_jms.HelloWorldServiceRuntimeCorrelationIDStaticPrefix)1 AbstractVmJMSTest (org.apache.cxf.systest.jms.AbstractVmJMSTest)1 Test (org.junit.Test)1