use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class JndiPasProducerCase method testProduceAndConsumeUsingJndiOnly.
@Test
public void testProduceAndConsumeUsingJndiOnly() throws Exception {
String queueName = testName.getMethodName() + "_queue";
String topicName = testName.getMethodName() + "_topic";
StandardJndiImplementation recvVendorImp = createVendorImplementation();
StandardJndiImplementation sendVendorImp = createVendorImplementation();
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPasConnection(recvVendorImp, true, queueName, topicName), new PasConsumer().withTopic(topicName));
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPasConnection(sendVendorImp, true, queueName, topicName), new PasProducer().withTopic(topicName));
execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
assertMessages(jms);
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class JmxNotificationConsumerTest method testConsumer_NoUserData.
@Test
public void testConsumer_NoUserData() throws Exception {
MBeanServer mbeanServer = JmxHelper.findMBeanServer();
String myObjectName = "com.adaptris:type=Junit,id=" + getName();
StubNotificationBroadcaster broadcast = new StubNotificationBroadcaster();
MockMessageListener listener = new MockMessageListener();
JmxNotificationConsumer consumer = new JmxNotificationConsumer();
consumer.setObjectName(myObjectName);
StandaloneConsumer sc = wrap(new JmxConnection(), consumer, listener);
try {
mbeanServer.registerMBean(broadcast, ObjectName.getInstance(myObjectName));
start(sc);
broadcast.sendNotification(getName(), null);
waitForMessages(listener, 1);
assertEquals(1, listener.messageCount());
assertNull(listener.getMessages().get(0).getObjectHeaders().get(NotificationSerializer.OBJ_METADATA_USERDATA));
} finally {
stop(sc);
}
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class JmxNotificationConsumerTest method testNotFound.
@Test
public void testNotFound() throws Exception {
MBeanServer mbeanServer = JmxHelper.findMBeanServer();
String myObjectName = "com.adaptris:type=Junit,id=" + getName();
StubNotificationBroadcaster broadcast = new StubNotificationBroadcaster();
MockMessageListener listener = new MockMessageListener();
JmxNotificationConsumer consumer = new JmxNotificationConsumer();
consumer.setObjectName(myObjectName);
StandaloneConsumer sc = wrap(new JmxConnection(), consumer, listener);
try {
start(sc);
fail();
} catch (CoreException e) {
} finally {
stop(sc);
}
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class JmxNotificationConsumerTest method testNotFound_Retry.
@Test
public void testNotFound_Retry() throws Exception {
final MBeanServer mbeanServer = JmxHelper.findMBeanServer();
final String myObjectName = "com.adaptris:type=Junit,id=" + getName();
final StubNotificationBroadcaster broadcast = new StubNotificationBroadcaster();
MockMessageListener listener = new MockMessageListener();
JmxNotificationConsumer consumer = new JmxNotificationConsumer();
consumer.setFailIfNotFound(false);
consumer.setRetryInterval(new TimeInterval(1L, TimeUnit.SECONDS));
consumer.setObjectName(myObjectName);
StandaloneConsumer sc = wrap(new JmxConnection(), consumer, listener);
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new ManagedThreadFactory(getClass().getSimpleName()));
try {
start(sc);
scheduler.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
try {
if (!mbeanServer.isRegistered(ObjectName.getInstance(myObjectName))) {
mbeanServer.registerMBean(broadcast, ObjectName.getInstance(myObjectName));
}
broadcast.sendNotification(getName(), new Object());
} catch (Exception e) {
throw new RuntimeException();
}
}
}, 3, 1, TimeUnit.SECONDS);
waitForMessages(listener, 1);
assertTrue(listener.messageCount() >= 1);
assertNotNull(listener.getMessages().get(0).getObjectHeaders().get(NotificationSerializer.OBJ_METADATA_USERDATA));
} catch (CoreException e) {
} finally {
stop(sc);
ManagedThreadFactory.shutdownQuietly(scheduler, 100L);
}
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class PtpPollingConsumerTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
PtpPollingConsumer consumer = new PtpPollingConsumer();
consumer.setQueue("MyQueueName");
consumer.setPoller(new FixedIntervalPoller(new TimeInterval(1L, TimeUnit.MINUTES)));
consumer.setUserName("user-name");
consumer.setPassword("password");
consumer.setClientId("client-id");
consumer.setReacquireLockBetweenMessages(true);
StandaloneConsumer result = new StandaloneConsumer(consumer);
return result;
}
Aggregations