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());
}
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());
}
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;
}
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());
}
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;
}
}
Aggregations