use of com.adaptris.core.interceptor.MessageMetricsInterceptor in project interlok by adaptris.
the class WorkflowManagerTest method testMessageCounter_Enabled_AlreadyHasMessageCounter.
@Test
public void testMessageCounter_Enabled_AlreadyHasMessageCounter() 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);
Workflow workflow = createWorkflow("w1");
workflow.getInterceptors().add(new MessageMetricsInterceptor(getName(), null));
new WorkflowManager(workflow, channelManager);
assertEquals(2, workflow.getInterceptors().size());
assertEquals(MessageMetricsInterceptor.class, workflow.getInterceptors().get(0).getClass());
assertEquals(getName(), workflow.getInterceptors().get(0).getUniqueId());
assertEquals(InFlightWorkflowInterceptor.class, workflow.getInterceptors().get(1).getClass());
}
use of com.adaptris.core.interceptor.MessageMetricsInterceptor in project interlok by adaptris.
the class WorkflowManager method configureMessageCounter.
private void configureMessageCounter() throws CoreException, MalformedObjectNameException {
if (managedWorkflow.disableMessageCount())
return;
if (!hasInterceptorOfType(managedWorkflow.getInterceptors(), MessageMetricsInterceptor.class)) {
log.trace("Message count interceptor added for [{}], tracks metrics for ~1hr", createObjectName());
String uid = managedWorkflow.getUniqueId() + MessageMetricsInterceptor.UID_SUFFIX;
managedWorkflow.getInterceptors().add(new MessageMetricsInterceptor(uid, new TimeInterval(5L, TimeUnit.MINUTES), 12));
}
if (!hasInterceptorOfType(managedWorkflow.getInterceptors(), InFlightWorkflowInterceptor.class)) {
log.trace("InFlight interceptor added for [{}]", createObjectName());
String uid = managedWorkflow.getUniqueId() + InFlightWorkflowInterceptor.UID_SUFFIX;
managedWorkflow.getInterceptors().add(new InFlightWorkflowInterceptor(uid));
}
}
use of com.adaptris.core.interceptor.MessageMetricsInterceptor in project interlok by adaptris.
the class AdapterManagerTest method testRegisterMBean.
@Test
public void testRegisterMBean() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
Channel channel = createChannel("c1");
Workflow workflow = createWorkflow("w1");
workflow.getInterceptors().add(new MessageMetricsInterceptor());
channel.getWorkflowList().add(workflow);
adapter.getChannelList().add(channel);
AdapterManager adapterManager = new AdapterManager(adapter);
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
adapterManager.registerMBean();
assertTrue(JmxHelper.findMBeanServer().isRegistered(adapterManager.createObjectName()));
for (BaseComponentMBean baseMBean : adapterManager.getAllDescendants()) {
assertTrue(JmxHelper.findMBeanServer().isRegistered(baseMBean.createObjectName()));
}
adapterManager.unregisterMBean();
assertFalse(JmxHelper.findMBeanServer().isRegistered(adapterManager.createObjectName()));
for (BaseComponentMBean baseMBean : adapterManager.getAllDescendants()) {
assertFalse(JmxHelper.findMBeanServer().isRegistered(baseMBean.createObjectName()));
}
register(mBeans);
assertTrue(JmxHelper.findMBeanServer().isRegistered(adapterManager.createObjectName()));
for (BaseComponentMBean baseMBean : adapterManager.getAllDescendants()) {
assertTrue(JmxHelper.findMBeanServer().isRegistered(baseMBean.createObjectName()));
}
} finally {
}
}
use of com.adaptris.core.interceptor.MessageMetricsInterceptor in project interlok by adaptris.
the class WorkflowManagerTest method testConstructor_WithInterceptor_RuntimeInfoFactoryRegistered.
@Test
public void testConstructor_WithInterceptor_RuntimeInfoFactoryRegistered() 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);
StandardWorkflow workflow = createWorkflow("w1");
workflow.setDisableDefaultMessageCount(true);
workflow.getInterceptors().add(new MessageMetricsInterceptor());
WorkflowManager workflowManager = new WorkflowManager(workflow, channelManager);
assertEquals(1, workflowManager.getChildRuntimeInfoComponents().size());
}
Aggregations