Search in sources :

Example 16 with JettyMessageConsumer

use of com.adaptris.core.http.jetty.JettyMessageConsumer in project interlok by adaptris.

the class WorkflowManagerTest method testJettyInterceptor_AlreadyHasInterceptor.

@Test
public void testJettyInterceptor_AlreadyHasInterceptor() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager adapterManager = new AdapterManager(adapter);
    Channel channel = createChannel("c1");
    ChannelManager channelManager = new ChannelManager(channel, adapterManager);
    PoolingWorkflow workflow = new PoolingWorkflow("w1");
    workflow.addInterceptor(new JettyPoolingWorkflowInterceptor());
    workflow.setConsumer(new JettyMessageConsumer());
    new WorkflowManager(workflow, channelManager);
    assertEquals(3, workflow.getInterceptors().size());
    // Look the order should now be swapped.
    assertEquals(JettyPoolingWorkflowInterceptor.class, workflow.getInterceptors().get(0).getClass());
    assertEquals(MessageMetricsInterceptor.class, workflow.getInterceptors().get(1).getClass());
    assertEquals(InFlightWorkflowInterceptor.class, workflow.getInterceptors().get(2).getClass());
}
Also used : Channel(com.adaptris.core.Channel) JettyPoolingWorkflowInterceptor(com.adaptris.core.http.jetty.JettyPoolingWorkflowInterceptor) Adapter(com.adaptris.core.Adapter) JettyMessageConsumer(com.adaptris.core.http.jetty.JettyMessageConsumer) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) Test(org.junit.Test)

Example 17 with JettyMessageConsumer

use of com.adaptris.core.http.jetty.JettyMessageConsumer in project interlok by adaptris.

the class WorkflowManagerTest method testJettyInterceptor_AutoAdded.

@Test
public void testJettyInterceptor_AutoAdded() throws Exception {
    String adapterName = this.getClass().getSimpleName() + "." + getName();
    Adapter adapter = createAdapter(adapterName);
    AdapterManager adapterManager = new AdapterManager(adapter);
    Channel channel = createChannel("c1");
    ChannelManager channelManager = new ChannelManager(channel, adapterManager);
    PoolingWorkflow workflow = new PoolingWorkflow("w1");
    workflow.setConsumer(new JettyMessageConsumer());
    new WorkflowManager(workflow, channelManager);
    assertEquals(3, workflow.getInterceptors().size());
    assertEquals(MessageMetricsInterceptor.class, workflow.getInterceptors().get(0).getClass());
    assertEquals(InFlightWorkflowInterceptor.class, workflow.getInterceptors().get(1).getClass());
    assertEquals(JettyPoolingWorkflowInterceptor.class, workflow.getInterceptors().get(2).getClass());
}
Also used : Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) JettyMessageConsumer(com.adaptris.core.http.jetty.JettyMessageConsumer) PoolingWorkflow(com.adaptris.core.PoolingWorkflow) Test(org.junit.Test)

Example 18 with JettyMessageConsumer

use of com.adaptris.core.http.jetty.JettyMessageConsumer in project interlok by adaptris.

the class HttpHelper method createAndStartChannel.

public static Channel createAndStartChannel(MockMessageProducer mock, String replyPayload, HttpStatusProvider.HttpStatus status) throws Exception {
    JettyMessageConsumer mc = createConsumer(URL_TO_POST_TO);
    mc.setHeaderHandler(new MetadataHeaderHandler());
    HttpConnection jc = createConnection();
    Channel c = createChannel(jc, createWorkflow(mc, mock, new ServiceList(new Service[] { new PayloadFromTemplateService().withTemplate(replyPayload), new StandaloneProducer(new StandardResponseProducer(status)) })));
    start(c);
    return c;
}
Also used : MetadataHeaderHandler(com.adaptris.core.http.jetty.MetadataHeaderHandler) HttpConnection(com.adaptris.core.http.jetty.HttpConnection) StandardResponseProducer(com.adaptris.core.http.jetty.StandardResponseProducer) ServiceList(com.adaptris.core.ServiceList) JettyHelper.createChannel(com.adaptris.core.http.jetty.JettyHelper.createChannel) Channel(com.adaptris.core.Channel) JettyMessageConsumer(com.adaptris.core.http.jetty.JettyMessageConsumer) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) StandaloneProducer(com.adaptris.core.StandaloneProducer)

Example 19 with JettyMessageConsumer

use of com.adaptris.core.http.jetty.JettyMessageConsumer in project interlok by adaptris.

the class HttpRequestServiceTest method testRequest_GetMethod_NonZeroBytes.

@Test
public void testRequest_GetMethod_NonZeroBytes() throws Exception {
    MockMessageProducer mock = new MockMessageProducer();
    HttpConnection jc = HttpHelper.createConnection();
    JettyMessageConsumer mc = createConsumer(HttpHelper.URL_TO_POST_TO);
    Channel c = createChannel(jc, createWorkflow(mc, mock, new ServiceList(new Service[] { new PayloadFromTemplateService().withTemplate(TEXT), new StandaloneProducer(new StandardResponseProducer(HttpStatus.OK_200)) })));
    HttpRequestService service = new HttpRequestService(HttpHelper.createProduceDestination(c)).withMethod("GET");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage("Hello World");
    try {
        start(c);
        execute(service, msg);
        waitForMessages(mock, 1);
    } finally {
        stop(c);
    }
    assertEquals(1, mock.messageCount());
    AdaptrisMessage m2 = mock.getMessages().get(0);
    assertEquals("GET", m2.getMetadataValue(CoreConstants.HTTP_METHOD));
    assertEquals(TEXT, msg.getContent());
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) HttpConnection(com.adaptris.core.http.jetty.HttpConnection) StandardResponseProducer(com.adaptris.core.http.jetty.StandardResponseProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) JettyHelper.createChannel(com.adaptris.core.http.jetty.JettyHelper.createChannel) Channel(com.adaptris.core.Channel) JettyMessageConsumer(com.adaptris.core.http.jetty.JettyMessageConsumer) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test) HttpConsumerTest(com.adaptris.core.http.jetty.HttpConsumerTest)

Example 20 with JettyMessageConsumer

use of com.adaptris.core.http.jetty.JettyMessageConsumer in project interlok by adaptris.

the class RetryFromJetty method prepare.

@Override
public void prepare() throws CoreException {
    if (!prepared) {
        Args.notNull(getReportBuilder(), "report-builder");
        Args.notNull(getRetryStore(), "retry-store");
        String retryServletPath = retryEndpointPrefix() + "*";
        String retryServletRegexp = "^" + retryEndpointPrefix() + "(.*)";
        String deleteServletPath = deleteEndpointPrefix() + "*";
        String deleteServletRegexp = "^" + deleteEndpointPrefix() + "(.*)";
        retryRouting = new JettyRouteCondition().withUrlPattern(retryServletRegexp).withMetadataKeys(MSG_ID_KEY).withMethod(retryHttpMethod());
        deleteRouting = new JettyRouteCondition().withUrlPattern(deleteServletRegexp).withMetadataKeys(MSG_ID_KEY).withMethod(deleteHttpMethod());
        reporter = new ReportListener();
        retrier = new RetryListener();
        deleter = new DeleteListener();
        // By not dictating the method in the consumer; we accept all methods in jetty, but we use the
        // jetty route filter to filter it out.
        retrying = new StandaloneConsumer(getConnection(), new JettyMessageConsumer().withPath(retryServletPath));
        deleting = new StandaloneConsumer(getConnection(), new JettyMessageConsumer().withPath(deleteServletPath));
        reporting = new StandaloneConsumer(getConnection(), new JettyMessageConsumer().withPath(reportingEndpoint()));
        retrying.registerAdaptrisMessageListener(retrier);
        reporting.registerAdaptrisMessageListener(reporter);
        deleting.registerAdaptrisMessageListener(deleter);
        LifecycleHelper.prepare(getRetryStore(), getReportBuilder());
        LifecycleHelper.prepare(deleteRouting, deleter, deleting);
        LifecycleHelper.prepare(retryRouting, retrier, retrying);
        LifecycleHelper.prepare(reporter, reporting);
        prepared = true;
    }
}
Also used : JettyRouteCondition(com.adaptris.core.http.jetty.JettyRouteCondition) JettyMessageConsumer(com.adaptris.core.http.jetty.JettyMessageConsumer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer)

Aggregations

JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)29 Channel (com.adaptris.core.Channel)28 Test (org.junit.Test)26 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)25 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)25 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)23 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)23 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)23 ServiceList (com.adaptris.core.ServiceList)20 StandaloneProducer (com.adaptris.core.StandaloneProducer)20 StandardResponseProducer (com.adaptris.core.http.jetty.StandardResponseProducer)20 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)18 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)12 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)12 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)11 StandardWorkflow (com.adaptris.core.StandardWorkflow)10 ConfigurableSecurityHandler (com.adaptris.core.http.jetty.ConfigurableSecurityHandler)5 HashLoginServiceFactory (com.adaptris.core.http.jetty.HashLoginServiceFactory)5 SecurityConstraint (com.adaptris.core.http.jetty.SecurityConstraint)5 NullConnection (com.adaptris.core.NullConnection)4