Search in sources :

Example 1 with WorkerPool

use of org.apache.axis2.transport.base.threads.WorkerPool in project wso2-axis2-transports by wso2.

the class RabbitMQEndpoint method loadConfiguration.

@Override
public boolean loadConfiguration(ParameterInclude params) throws AxisFault {
    // We only support endpoints configured at service level
    if (!(params instanceof AxisService)) {
        return false;
    }
    AxisService service = (AxisService) params;
    rabbitMQConnectionFactory = rabbitMQListener.getConnectionFactory(service);
    if (rabbitMQConnectionFactory == null) {
        return false;
    }
    serviceTaskManager = ServiceTaskManagerFactory.createTaskManagerForService(rabbitMQConnectionFactory, service, workerPool);
    serviceTaskManager.setRabbitMQMessageReceiver(new RabbitMQMessageReceiver(rabbitMQListener, rabbitMQConnectionFactory, this));
    return true;
}
Also used : AxisService(org.apache.axis2.description.AxisService)

Example 2 with WorkerPool

use of org.apache.axis2.transport.base.threads.WorkerPool in project wso2-synapse by wso2.

the class PassThroughHttpSenderTest method testInit.

/**
 * This method tests the initialization of PassThroughHttpSender
 * @throws Exception
 */
@Test
public void testInit() throws Exception {
    ConfigurationContext configurationContext = new ConfigurationContext(new AxisConfiguration());
    WorkerPool workerPool = new NativeWorkerPool(3, 4, 5, 5, "name", "id");
    configurationContext.setProperty(PassThroughConstants.PASS_THROUGH_TRANSPORT_WORKER_POOL, workerPool);
    TransportOutDescription transportOutDescription = new TransportOutDescription("passthru");
    PassThroughHttpSender passThroughHttpSender = new PassThroughHttpSender();
    passThroughHttpSender.init(configurationContext, transportOutDescription);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) TransportOutDescription(org.apache.axis2.description.TransportOutDescription) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with WorkerPool

use of org.apache.axis2.transport.base.threads.WorkerPool in project wso2-synapse by wso2.

the class TargetResponseTest method testTrue.

/**
 * Testing the starting of target response when response body is expected
 *
 * @throws Exception
 */
@Test
public void testTrue() throws Exception {
    ConfigurationContext configurationContext = new ConfigurationContext(new AxisConfiguration());
    WorkerPool workerPool = new NativeWorkerPool(3, 4, 5, 5, "name", "id");
    PassThroughTransportMetricsCollector metrics = new PassThroughTransportMetricsCollector(true, "testScheme");
    TargetConfiguration targetConfiguration = new TargetConfiguration(configurationContext, null, workerPool, metrics, null);
    targetConfiguration.build();
    HttpResponse response = PowerMockito.mock(HttpResponse.class, Mockito.RETURNS_DEEP_STUBS);
    NHttpClientConnection conn = PowerMockito.mock(NHttpClientConnection.class, Mockito.RETURNS_DEEP_STUBS);
    PowerMockito.mockStatic(TargetContext.class);
    TargetContext cntxt = new TargetContext(targetConfiguration);
    PowerMockito.when(TargetContext.get(any(NHttpClientConnection.class))).thenReturn(cntxt);
    TargetResponse targetResponse = new TargetResponse(targetConfiguration, response, conn, true, false);
    try {
        targetResponse.start(conn);
    } catch (Exception e) {
        logger.error(e);
        Assert.fail("Unable to start the target response!");
    }
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) TargetConfiguration(org.apache.synapse.transport.passthru.config.TargetConfiguration) PassThroughTransportMetricsCollector(org.apache.synapse.transport.passthru.jmx.PassThroughTransportMetricsCollector) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) HttpResponse(org.apache.http.HttpResponse) NHttpClientConnection(org.apache.http.nio.NHttpClientConnection) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with WorkerPool

use of org.apache.axis2.transport.base.threads.WorkerPool in project wso2-synapse by wso2.

the class TargetResponseTest method testFalse.

/**
 * Testing the starting of target response when response body is not expected
 *
 * @throws Exception
 */
@Test
public void testFalse() throws Exception {
    ConfigurationContext configurationContext = new ConfigurationContext(new AxisConfiguration());
    WorkerPool workerPool = new NativeWorkerPool(3, 4, 5, 5, "name", "id");
    PassThroughTransportMetricsCollector metrics = new PassThroughTransportMetricsCollector(true, "testScheme");
    TargetConfiguration targetConfiguration = new TargetConfiguration(configurationContext, null, workerPool, metrics, null);
    HttpResponse response = PowerMockito.mock(HttpResponse.class, Mockito.RETURNS_DEEP_STUBS);
    NHttpClientConnection conn = PowerMockito.mock(NHttpClientConnection.class, Mockito.RETURNS_DEEP_STUBS);
    TargetConnections connections = PowerMockito.mock(TargetConnections.class);
    targetConfiguration.setConnections(connections);
    PowerMockito.mockStatic(TargetContext.class);
    TargetResponse targetResponse = new TargetResponse(targetConfiguration, response, conn, false, false);
    try {
        targetResponse.start(conn);
    } catch (Exception e) {
        logger.error(e);
        Assert.fail("Unable to start the target response!");
    }
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) TargetConfiguration(org.apache.synapse.transport.passthru.config.TargetConfiguration) PassThroughTransportMetricsCollector(org.apache.synapse.transport.passthru.jmx.PassThroughTransportMetricsCollector) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) HttpResponse(org.apache.http.HttpResponse) TargetConnections(org.apache.synapse.transport.passthru.connections.TargetConnections) NHttpClientConnection(org.apache.http.nio.NHttpClientConnection) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with WorkerPool

use of org.apache.axis2.transport.base.threads.WorkerPool in project wso2-synapse by wso2.

the class TargetResponseTest method testRead.

/**
 * Testing reading from a pipe
 * @throws Exception
 */
@Test
public void testRead() throws Exception {
    ConfigurationContext configurationContext = new ConfigurationContext(new AxisConfiguration());
    WorkerPool workerPool = new NativeWorkerPool(3, 4, 5, 5, "name", "id");
    PassThroughTransportMetricsCollector metrics = new PassThroughTransportMetricsCollector(true, "testScheme");
    TargetConfiguration targetConfiguration = new TargetConfiguration(configurationContext, null, workerPool, metrics, null);
    targetConfiguration.build();
    HttpResponse response = PowerMockito.mock(HttpResponse.class, Mockito.RETURNS_DEEP_STUBS);
    NHttpClientConnection conn = PowerMockito.mock(NHttpClientConnection.class, Mockito.RETURNS_DEEP_STUBS);
    ContentDecoder decoder = PowerMockito.mock(ContentDecoder.class);
    TargetConnections connections = PowerMockito.mock(TargetConnections.class);
    targetConfiguration.setConnections(connections);
    PowerMockito.mockStatic(TargetContext.class);
    TargetContext cntxt = new TargetContext(targetConfiguration);
    PowerMockito.when(TargetContext.get(any(NHttpClientConnection.class))).thenReturn(cntxt);
    PowerMockito.when(decoder.read(any(ByteBuffer.class))).thenReturn(12);
    PowerMockito.when(decoder.isCompleted()).thenReturn(true);
    TargetResponse targetResponse = new TargetResponse(targetConfiguration, response, conn, true, false);
    targetResponse.start(conn);
    int result = targetResponse.read(conn, decoder);
    Assert.assertEquals(12, result);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) TargetConfiguration(org.apache.synapse.transport.passthru.config.TargetConfiguration) PassThroughTransportMetricsCollector(org.apache.synapse.transport.passthru.jmx.PassThroughTransportMetricsCollector) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) ContentDecoder(org.apache.http.nio.ContentDecoder) HttpResponse(org.apache.http.HttpResponse) NHttpClientConnection(org.apache.http.nio.NHttpClientConnection) ByteBuffer(java.nio.ByteBuffer) WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) TargetConnections(org.apache.synapse.transport.passthru.connections.TargetConnections) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

WorkerPool (org.apache.axis2.transport.base.threads.WorkerPool)15 Test (org.junit.Test)12 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)11 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)11 NativeWorkerPool (org.apache.axis2.transport.base.threads.NativeWorkerPool)11 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)10 PassThroughTransportMetricsCollector (org.apache.synapse.transport.passthru.jmx.PassThroughTransportMetricsCollector)8 TargetConfiguration (org.apache.synapse.transport.passthru.config.TargetConfiguration)6 AxisService (org.apache.axis2.description.AxisService)5 Parameter (org.apache.axis2.description.Parameter)5 NHttpClientConnection (org.apache.http.nio.NHttpClientConnection)5 HttpResponse (org.apache.http.HttpResponse)3 TargetConnections (org.apache.synapse.transport.passthru.connections.TargetConnections)3 Message (quickfix.Message)3 SessionID (quickfix.SessionID)3 BeginString (quickfix.field.BeginString)3 MsgSeqNum (quickfix.field.MsgSeqNum)3 MsgType (quickfix.field.MsgType)3 SenderCompID (quickfix.field.SenderCompID)3 TargetCompID (quickfix.field.TargetCompID)3