use of com.adaptris.interlok.management.MessageProcessor in project interlok by adaptris.
the class MessageMetricsStatisticsByMetadataTest method testGetMessageStatistics.
@Override
public void testGetMessageStatistics() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
String payload = "SomePayload";
MessageMetricsInterceptorByMetadata interceptor = createInterceptor();
interceptor.setUniqueId(getName());
Adapter adapter = createSingleChannelAdapter(adapterName, interceptor);
List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
try {
start(adapter);
register(mBeans);
ObjectName workflowObj = createWorkflowObjectName(adapterName);
ObjectName metricsObj = createMetricsObjectName(adapterName, getName());
MessageMetricsStatisticsMBean stats = JMX.newMBeanProxy(mBeanServer, metricsObj, MessageMetricsStatisticsMBean.class);
MessageProcessor workflow = JMX.newMBeanProxy(mBeanServer, workflowObj, MessageProcessor.class);
workflow.processAsync(createMessageForInjection(payload));
assertEquals(1, stats.getStatistics().size());
assertEquals(interceptor.getStats().size(), stats.getStatistics().size());
MessageStatistic interceptorStat = (MessageStatistic) interceptor.getStats().get(0);
MessageStatistic mbeanStat = stats.getStatistics().get(0);
// They're not objectively equals (not clones), and no equals method.
assertNotSame(interceptorStat, mbeanStat);
assertEquals(interceptorStat.getEndMillis(), mbeanStat.getEndMillis());
assertEquals(interceptorStat.getTotalMessageCount(), mbeanStat.getTotalMessageCount());
assertEquals(interceptorStat.getTotalMessageErrorCount(), mbeanStat.getTotalMessageErrorCount());
assertEquals(interceptorStat.getTotalMessageSize(), mbeanStat.getTotalMessageSize());
} finally {
stop(adapter);
}
}
use of com.adaptris.interlok.management.MessageProcessor in project interlok by adaptris.
the class MessageMetricsStatisticsTest method testGetMessageStatistics.
@Test
public void testGetMessageStatistics() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
String payload = "SomePayload";
MessageMetricsInterceptor interceptor = (MessageMetricsInterceptor) createInterceptor();
interceptor.setUniqueId(getName());
Adapter adapter = createSingleChannelAdapter(adapterName, interceptor);
List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
try {
start(adapter);
register(mBeans);
ObjectName workflowObj = createWorkflowObjectName(adapterName);
ObjectName metricsObj = createMetricsObjectName(adapterName, getName());
MessageMetricsStatisticsMBean stats = JMX.newMBeanProxy(mBeanServer, metricsObj, MessageMetricsStatisticsMBean.class);
MessageProcessor workflow = JMX.newMBeanProxy(mBeanServer, workflowObj, MessageProcessor.class);
workflow.processAsync(createMessageForInjection(payload));
assertEquals(1, stats.getStatistics().size());
assertEquals(interceptor.getStats().size(), stats.getStatistics().size());
MessageStatistic interceptorStat = (MessageStatistic) interceptor.getStats().get(0);
MessageStatistic mbeanStat = stats.getStatistics().get(0);
// They're not objectively equals (not clones), and no equals method.
assertNotSame(interceptorStat, mbeanStat);
assertEquals(interceptorStat.getEndMillis(), mbeanStat.getEndMillis());
assertEquals(interceptorStat.getTotalMessageCount(), mbeanStat.getTotalMessageCount());
assertEquals(interceptorStat.getTotalMessageErrorCount(), mbeanStat.getTotalMessageErrorCount());
assertEquals(interceptorStat.getTotalMessageSize(), mbeanStat.getTotalMessageSize());
} finally {
stop(adapter);
}
}
use of com.adaptris.interlok.management.MessageProcessor in project interlok by adaptris.
the class WorkflowManagerTest method testProcess.
@Test
public void testProcess() 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.getServiceCollection().add(new AddMetadataService(Arrays.asList(new MetadataElement(getName(), getName()))));
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
channelManager.createObjectName();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
String msgUniqueId = new GuidGenerator().getUUID();
SerializableMessage msg = createSM(msgUniqueId);
try {
register(mBeans);
MessageProcessor workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, MessageProcessor.class);
adapterManager.requestStart();
SerializableMessage reply = workflowManagerProxy.process(msg);
assertEquals(msgUniqueId, reply.getUniqueId());
assertEquals(PAYLOAD, reply.getContent());
assertEquals(PAYLOAD_ENCODING, reply.getContentEncoding());
Map<String, String> headers = reply.getMessageHeaders();
assertTrue(headers.containsKey(METADATA_KEY));
assertEquals(METADATA_VALUE, headers.get(METADATA_KEY));
assertTrue(headers.containsKey(getName()));
assertEquals(getName(), headers.get(getName()));
assertEquals("", reply.getNextServiceId());
} finally {
adapter.requestClose();
}
}
use of com.adaptris.interlok.management.MessageProcessor in project interlok by adaptris.
the class WorkflowManagerTest method testProcessAsync.
@Test
public void testProcessAsync() 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");
MockMessageProducer mockProducer = new MockMessageProducer();
workflow.setProducer(mockProducer);
WorkflowManager realWorkflowManager = new WorkflowManager(workflow, channelManager);
adapterManager.createObjectName();
ObjectName workflowObj = realWorkflowManager.createObjectName();
channelManager.createObjectName();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
String msgUniqueId = new GuidGenerator().getUUID();
SerializableMessage msg = createSM(msgUniqueId);
try {
register(mBeans);
MessageProcessor workflowManagerProxy = JMX.newMBeanProxy(mBeanServer, workflowObj, MessageProcessor.class);
adapterManager.requestStart();
workflowManagerProxy.processAsync(msg);
assertEquals(1, mockProducer.getMessages().size());
AdaptrisMessage procMsg = mockProducer.getMessages().get(0);
assertEquals(msgUniqueId, procMsg.getUniqueId());
assertEquals(PAYLOAD, procMsg.getContent());
assertEquals(PAYLOAD_ENCODING, procMsg.getContentEncoding());
assertTrue(procMsg.headersContainsKey(METADATA_KEY));
assertEquals(METADATA_VALUE, procMsg.getMetadataValue(METADATA_KEY));
} finally {
adapter.requestClose();
}
}
use of com.adaptris.interlok.management.MessageProcessor in project interlok by adaptris.
the class InterlokJmxClient method findWorkflow.
private MessageProcessor findWorkflow(MessageTarget target) throws InterlokException {
MessageProcessor workflowProxy = null;
try {
ObjectName queryName = ObjectName.getInstance(String.format(JMX_WORKFLOW_MANAGER_NAME, target.getAdapter(), target.getChannel(), target.getWorkflow()));
MBeanServerConnection mbeanServer = getConnection();
ArrayList<ObjectName> names = new ArrayList(mbeanServer.queryNames(queryName, null));
if (names.size() == 0 || names.size() > 1) {
throw new InterlokException(queryName + " does not narrow to a single workflow");
}
workflowProxy = JMX.newMBeanProxy(mbeanServer, names.get(0), MessageProcessor.class);
} catch (Exception e) {
rethrowInterlokException(e);
}
return workflowProxy;
}
Aggregations