use of org.apache.camel.PollingConsumer in project syncope by apache.
the class CamelUserProvisioningManager method reactivate.
@Override
@SuppressWarnings("unchecked")
public Pair<String, List<PropagationStatus>> reactivate(final StatusPatch statusPatch, final boolean nullPriorityAsync) {
PollingConsumer pollingConsumer = getConsumer("direct:statusPort");
Map<String, Object> props = new HashMap<>();
props.put("key", statusPatch.getKey());
props.put("statusPatch", statusPatch);
props.put("nullPriorityAsync", nullPriorityAsync);
if (statusPatch.isOnSyncope()) {
sendMessage("direct:reactivateUser", statusPatch.getKey(), props);
} else {
WorkflowResult<String> updated = new WorkflowResult<>(statusPatch.getKey(), null, statusPatch.getType().name().toLowerCase());
sendMessage("direct:userStatusPropagation", updated, 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 CamelUserProvisioningManager method unlink.
@Override
public String unlink(final UserPatch userPatch) {
PollingConsumer pollingConsumer = getConsumer("direct:unlinkPort");
sendMessage("direct:unlinkUser", userPatch);
Exchange exchange = pollingConsumer.receive();
if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
}
return exchange.getIn().getBody(UserPatch.class).getKey();
}
use of org.apache.camel.PollingConsumer in project wildfly-camel by wildfly-extras.
the class CXFWSSecureProducerIntegrationTest method testEndpointRouteWithInvalidCredentials.
@Test
public void testEndpointRouteWithInvalidCredentials() throws Exception {
deployer.deploy(SIMPLE_WAR);
try {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").doTry().to("cxf://" + getEndpointAddress("/simple", "baduser", "badpassword")).doCatch(Exception.class).setBody(exceptionMessage()).to("direct:error").end();
}
});
PollingConsumer pollingConsumer = camelctx.getEndpoint("direct:error").createPollingConsumer();
pollingConsumer.start();
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
producer.requestBody("direct:start", "Kermit", String.class);
String result = pollingConsumer.receive(3000).getIn().getBody(String.class);
Assert.assertTrue(result.contains("401: Unauthorized"));
} finally {
camelctx.stop();
}
} finally {
deployer.undeploy(SIMPLE_WAR);
}
}
use of org.apache.camel.PollingConsumer in project wildfly-camel by wildfly-extras.
the class TransactedJMSIntegrationTest method testJMSTransactionToDLQ.
@Test
public void testJMSTransactionToDLQ() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addComponent("jms", jmsComponent);
camelctx.addRoutes(configureJmsRoutes());
camelctx.start();
PollingConsumer consumer = camelctx.getEndpoint("seda:dlq").createPollingConsumer();
consumer.start();
// Send a message to queue camel-jms-queue-one
Connection connection = connectionFactory.createConnection();
sendMessage(connection, JmsQueue.QUEUE_ONE.getJndiName(), "Hello Bob");
// The JMS transaction should have been rolled back and the message sent to the DLQ
String result = consumer.receive().getIn().getBody(String.class);
Assert.assertNotNull(result);
Assert.assertEquals("Hello Bob", result);
connection.close();
camelctx.stop();
}
use of org.apache.camel.PollingConsumer in project wildfly-camel by wildfly-extras.
the class SQLIntegrationTest method testSQLEndpoint.
@Test
public void testSQLEndpoint() throws Exception {
Assert.assertNotNull("DataSource not null", dataSource);
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("sql:select name from information_schema.users?dataSource=java:jboss/datasources/ExampleDS").to("seda:end");
}
});
PollingConsumer pollingConsumer = camelctx.getEndpoint("seda:end").createPollingConsumer();
pollingConsumer.start();
camelctx.start();
try {
String result = (String) pollingConsumer.receive(3000).getIn().getBody(Map.class).get("NAME");
Assert.assertEquals("SA", result);
} finally {
camelctx.stop();
}
}
Aggregations