use of org.apache.camel.PollingConsumer in project camel by apache.
the class FtpConsumerDeleteNoWritePermissionTest method testConsumerDeleteNoWritePermission.
@Test
public void testConsumerDeleteNoWritePermission() throws Exception {
PollingConsumer consumer = context.getEndpoint(getFtpUrl()).createPollingConsumer();
consumer.start();
Exchange out = consumer.receive(3000);
assertNotNull("Should get the file", out);
try {
// give consumer time to try to delete the file
Thread.sleep(1000);
consumer.stop();
} catch (GenericFileOperationFailedException fofe) {
// expected, ignore
}
}
use of org.apache.camel.PollingConsumer in project camel by apache.
the class InvalidConfigurationTest method testSMTPSCanNotBeUsedForConsumingMails.
@Test
public void testSMTPSCanNotBeUsedForConsumingMails() throws Exception {
Endpoint endpoint = context.getEndpoint("smtps://localhost?username=james");
PollingConsumer consumer = endpoint.createPollingConsumer();
try {
consumer.start();
fail("Should have thrown NoSuchProviderException as stmp protocol cannot be used for consuming mails");
} catch (IllegalArgumentException e) {
// expected
}
}
use of org.apache.camel.PollingConsumer in project syncope by apache.
the class AbstractCamelProvisioningManager method getConsumer.
protected PollingConsumer getConsumer(final String uri) {
if (!knownURIs.contains(uri)) {
knownURIs.add(uri);
Endpoint endpoint = contextFactory.getCamelContext().getEndpoint(uri);
PollingConsumer pollingConsumer = null;
try {
pollingConsumer = endpoint.createPollingConsumer();
consumerMap.put(uri, pollingConsumer);
pollingConsumer.start();
} catch (Exception ex) {
LOG.error("Unexpected error in Consumer creation ", ex);
}
return pollingConsumer;
} else {
return consumerMap.get(uri);
}
}
use of org.apache.camel.PollingConsumer in project syncope by apache.
the class CamelAnyObjectProvisioningManager method update.
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public Pair<AnyObjectPatch, List<PropagationStatus>> update(final AnyObjectPatch anyPatch, final Set<String> excludedResources, final boolean nullPriorityAsync) {
PollingConsumer pollingConsumer = getConsumer("direct:updateAnyObjectPort");
Map<String, Object> props = new HashMap<>();
props.put("excludedResources", excludedResources);
props.put("nullPriorityAsync", nullPriorityAsync);
sendMessage("direct:updateAnyObject", anyPatch, props);
Exchange exchange = pollingConsumer.receive();
if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
}
return exchange.getIn().getBody(Pair.class);
}
use of org.apache.camel.PollingConsumer in project syncope by apache.
the class CamelAnyObjectProvisioningManager method unlink.
@Override
public String unlink(final AnyObjectPatch anyObjectPatch) {
PollingConsumer pollingConsumer = getConsumer("direct:unlinkAnyObjectPort");
sendMessage("direct:unlinkAnyObject", anyObjectPatch);
Exchange exchange = pollingConsumer.receive();
if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
}
return exchange.getIn().getBody(AnyObjectPatch.class).getKey();
}
Aggregations