Java Code Examples for org.apache.camel.PollingConsumer#receive()

The following examples show how to use org.apache.camel.PollingConsumer#receive() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CamelUserProvisioningManager.java    From syncope with Apache License 2.0 8 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<PropagationStatus> provision(
        final String key,
        final boolean changePwd,
        final String password,
        final Collection<String> resources,
        final boolean nullPriorityAsync,
        final String updater,
        final String context) {

    PollingConsumer pollingConsumer = getConsumer("direct:provisionPort");

    Map<String, Object> props = new HashMap<>();
    props.put("key", key);
    props.put("changePwd", changePwd);
    props.put("password", password);
    props.put("resources", resources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    props.put("updater", updater);
    props.put("context", context);

    sendMessage("direct:provisionUser", key, props);

    Exchange exchange = pollingConsumer.receive();

    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }

    return exchange.getIn().getBody(List.class);
}
 
Example 2
Source File: CamelUserProvisioningManager.java    From syncope with Apache License 2.0 8 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Pair<String, List<PropagationStatus>> suspend(
        final StatusR statusR, final boolean nullPriorityAsync, final String updater, final String context) {

    PollingConsumer pollingConsumer = getConsumer("direct:statusPort");

    Map<String, Object> props = new HashMap<>();
    props.put("key", statusR.getKey());
    props.put("statusR", statusR);
    props.put("nullPriorityAsync", nullPriorityAsync);
    props.put("updater", updater);
    props.put("context", context);

    if (statusR.isOnSyncope()) {
        sendMessage("direct:suspendUser", statusR.getKey(), props);
    } else {
        UserWorkflowResult<String> updated =
                new UserWorkflowResult<>(statusR.getKey(), null, null, statusR.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);
}
 
Example 3
Source File: AhcWSSIntegrationTest.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Test
public void testAsyncWssRoute() throws Exception {

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").to("ahc-wss:" + WEBSOCKET_ENDPOINT);
            from("ahc-wss:" + WEBSOCKET_ENDPOINT).to("seda:end");
        }
    });

    WsComponent wsComponent = (WsComponent) camelctx.getComponent("ahc-wss");
    wsComponent.setSslContextParameters(defineSSLContextClientParameters());

    PollingConsumer consumer = camelctx.getEndpoint("seda:end").createPollingConsumer();
    consumer.start();

    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        producer.sendBody("direct:start", "Kermit");

        Exchange exchange = consumer.receive(1000);
        Assert.assertEquals("Hello Kermit", exchange.getIn().getBody(String.class));

    } finally {
        camelctx.close();
    }
}
 
Example 4
Source File: CamelUserProvisioningManager.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
public void confirmPasswordReset(
        final String key, final String token, final String password, final String updater, final String context) {

    PollingConsumer pollingConsumer = getConsumer("direct:confirmPwdResetPort");

    Map<String, Object> props = new HashMap<>();
    props.put("key", key);
    props.put("token", token);
    props.put("password", password);
    props.put("updater", updater);
    props.put("context", context);

    sendMessage("direct:confirmPwdReset", key, props);

    Exchange exchange = pollingConsumer.receive();

    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }
}
 
Example 5
Source File: CamelUserProvisioningManager.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
public String unlink(final UserUR userUR, final String updater, final String context) {
    PollingConsumer pollingConsumer = getConsumer("direct:unlinkPort");

    Map<String, Object> props = new HashMap<>();
    props.put("updater", updater);
    props.put("context", context);

    sendMessage("direct:unlinkUser", userUR, props);

    Exchange exchange = pollingConsumer.receive();

    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }

    return exchange.getIn().getBody(UserUR.class).getKey();
}
 
Example 6
Source File: CamelGroupProvisioningManager.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
public String link(final GroupUR groupUR, final String updater, final String context) {
    PollingConsumer pollingConsumer = getConsumer("direct:linkGroupPort");

    Map<String, Object> props = new HashMap<>();
    props.put("updater", updater);
    props.put("context", context);

    sendMessage("direct:linkGroup", groupUR, props);

    Exchange exchange = pollingConsumer.receive();

    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }

    return exchange.getIn().getBody(GroupUR.class).getKey();
}
 
Example 7
Source File: CamelGroupProvisioningManager.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
public String unlink(final GroupUR groupUR, final String updater, final String context) {
    PollingConsumer pollingConsumer = getConsumer("direct:unlinkGroupPort");

    Map<String, Object> props = new HashMap<>();
    props.put("updater", updater);
    props.put("context", context);

    sendMessage("direct:unlinkGroup", groupUR, props);

    Exchange exchange = pollingConsumer.receive();

    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }

    return exchange.getIn().getBody(GroupUR.class).getKey();
}
 
Example 8
Source File: CamelUserProvisioningManager.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
public String link(final UserUR userUR, final String updater, final String context) {
    PollingConsumer pollingConsumer = getConsumer("direct:linkPort");

    Map<String, Object> props = new HashMap<>();
    props.put("updater", updater);
    props.put("context", context);

    sendMessage("direct:linkUser", userUR, props);

    Exchange exchange = pollingConsumer.receive();

    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }

    return exchange.getIn().getBody(UserUR.class).getKey();
}
 
Example 9
Source File: CamelUserProvisioningManager.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<PropagationStatus> deprovision(
        final String user,
        final Collection<String> resources,
        final boolean nullPriorityAsync,
        final String updater,
        final String context) {

    PollingConsumer pollingConsumer = getConsumer("direct:deprovisionPort");

    Map<String, Object> props = new HashMap<>();
    props.put("resources", resources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    props.put("updater", updater);
    props.put("context", context);

    sendMessage("direct:deprovisionUser", user, props);

    Exchange exchange = pollingConsumer.receive();

    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }

    return exchange.getIn().getBody(List.class);
}
 
Example 10
Source File: CamelAnyObjectProvisioningManager.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
public String link(final AnyObjectUR anyObjectUR, final String updater, final String context) {
    PollingConsumer pollingConsumer = getConsumer("direct:linkAnyObjectPort");

    Map<String, Object> props = new HashMap<>();
    props.put("updater", updater);
    props.put("context", context);

    sendMessage("direct:linkAnyObject", anyObjectUR, props);

    Exchange exchange = pollingConsumer.receive();

    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }

    return exchange.getIn().getBody(AnyObjectUR.class).getKey();
}
 
Example 11
Source File: CamelAnyObjectProvisioningManager.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
public String unlink(final AnyObjectUR anyObjectUR, final String updater, final String context) {
    PollingConsumer pollingConsumer = getConsumer("direct:unlinkAnyObjectPort");

    Map<String, Object> props = new HashMap<>();
    props.put("updater", updater);
    props.put("context", context);

    sendMessage("direct:unlinkAnyObject", anyObjectUR, props);

    Exchange exchange = pollingConsumer.receive();

    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }

    return exchange.getIn().getBody(AnyObjectUR.class).getKey();
}
 
Example 12
Source File: CamelGroupProvisioningManager.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public Pair<String, List<PropagationStatus>> create(
        final GroupCR req,
        final Map<String, String> groupOwnerMap,
        final Set<String> excludedResources,
        final boolean nullPriorityAsync,
        final String creator,
        final String context) {

    PollingConsumer pollingConsumer = getConsumer("direct:createGroupInPullPort");

    Map<String, Object> props = new HashMap<>();
    props.put("groupOwnerMap", groupOwnerMap);
    props.put("excludedResources", excludedResources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    props.put("creator", creator);
    props.put("context", context);

    sendMessage("direct:createGroupInPull", req, 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);
}
 
Example 13
Source File: CamelGroupProvisioningManager.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public List<PropagationStatus> delete(
        final String key,
        final Set<String> excludedResources,
        final boolean nullPriorityAsync,
        final String eraser,
        final String context) {

    PollingConsumer pollingConsumer = getConsumer("direct:deleteGroupPort");

    Map<String, Object> props = new HashMap<>();
    props.put("excludedResources", excludedResources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    props.put("eraser", eraser);
    props.put("context", context);

    sendMessage("direct:deleteGroup", key, props);

    Exchange exchange = pollingConsumer.receive();

    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }

    return exchange.getIn().getBody(List.class);
}
 
Example 14
Source File: CamelAnyObjectProvisioningManager.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<PropagationStatus> provision(
        final String key,
        final Collection<String> resources,
        final boolean nullPriorityAsync,
        final String updater,
        final String context) {

    PollingConsumer pollingConsumer = getConsumer("direct:provisionAnyObjectPort");

    Map<String, Object> props = new HashMap<>();
    props.put("resources", resources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    props.put("updater", updater);
    props.put("context", context);

    sendMessage("direct:provisionAnyObject", key, props);

    Exchange exchange = pollingConsumer.receive();

    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }

    return exchange.getIn().getBody(List.class);
}
 
Example 15
Source File: CamelGroupProvisioningManager.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public List<PropagationStatus> deprovision(
        final String key,
        final Collection<String> resources,
        final boolean nullPriorityAsync,
        final String updater,
        final String context) {

    PollingConsumer pollingConsumer = getConsumer("direct:deprovisionGroupPort");

    Map<String, Object> props = new HashMap<>();
    props.put("resources", resources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    props.put("updater", updater);
    props.put("context", context);

    sendMessage("direct:deprovisionGroup", key, props);

    Exchange exchange = pollingConsumer.receive();

    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }

    return exchange.getIn().getBody(List.class);
}
 
Example 16
Source File: CamelUserProvisioningManager.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public Pair<String, List<PropagationStatus>> create(
        final UserCR req,
        final boolean disablePwdPolicyCheck,
        final Boolean enabled,
        final Set<String> excludedResources,
        final boolean nullPriorityAsync,
        final String creator,
        final String context) {

    PollingConsumer pollingConsumer = getConsumer("direct:createPort");

    Map<String, Object> props = new HashMap<>();
    props.put("disablePwdPolicyCheck", disablePwdPolicyCheck);
    props.put("enabled", enabled);
    props.put("excludedResources", excludedResources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    props.put("creator", creator);
    props.put("context", context);

    sendMessage("direct:createUser", req, 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);
}
 
Example 17
Source File: CamelUserProvisioningManager.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public List<PropagationStatus> delete(
        final String key,
        final Set<String> excludedResources,
        final boolean nullPriorityAsync,
        final String eraser,
        final String context) {

    PollingConsumer pollingConsumer = getConsumer("direct:deletePort");

    Map<String, Object> props = new HashMap<>();
    props.put("excludedResources", excludedResources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    props.put("eraser", eraser);
    props.put("context", context);

    sendMessage("direct:deleteUser", key, props);

    Exchange exchange = pollingConsumer.receive();

    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }

    return exchange.getIn().getBody(List.class);
}
 
Example 18
Source File: CamelAnyObjectProvisioningManager.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public List<PropagationStatus> delete(
        final String key,
        final Set<String> excludedResources,
        final boolean nullPriorityAsync,
        final String eraser,
        final String context) {

    PollingConsumer pollingConsumer = getConsumer("direct:deleteAnyObjectPort");

    Map<String, Object> props = new HashMap<>();
    props.put("excludedResources", excludedResources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    props.put("eraser", eraser);
    props.put("context", context);

    sendMessage("direct:deleteAnyObject", key, props);

    Exchange exchange = pollingConsumer.receive();

    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }

    return exchange.getIn().getBody(List.class);
}
 
Example 19
Source File: CamelAnyObjectProvisioningManager.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public Pair<String, List<PropagationStatus>> create(
        final AnyObjectCR req,
        final Set<String> excludedResources,
        final boolean nullPriorityAsync,
        final String creator,
        final String context) {

    PollingConsumer pollingConsumer = getConsumer("direct:createAnyObjectPort");

    Map<String, Object> props = new HashMap<>();
    props.put("excludedResources", excludedResources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    props.put("creator", creator);
    props.put("context", context);

    sendMessage("direct:createAnyObject", req, 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);
}
 
Example 20
Source File: CamelUserProvisioningManager.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public Pair<UserUR, List<PropagationStatus>> update(
        final UserUR userUR,
        final ProvisioningReport result,
        final Boolean enabled,
        final Set<String> excludedResources,
        final boolean nullPriorityAsync,
        final String updater,
        final String context) {

    PollingConsumer pollingConsumer = getConsumer("direct:updateInPullPort");

    Map<String, Object> props = new HashMap<>();
    props.put("key", userUR.getKey());
    props.put("result", result);
    props.put("enabled", enabled);
    props.put("excludedResources", excludedResources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    props.put("updater", updater);
    props.put("context", context);

    sendMessage("direct:updateUserInPull", userUR, props);

    Exchange exchange = pollingConsumer.receive();

    Exception ex = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    if (ex != null) {
        LOG.error("Update of user {} failed, trying to pull its status anyway (if configured)",
                userUR.getKey(), ex);

        result.setStatus(ProvisioningReport.Status.FAILURE);
        result.setMessage("Update failed, trying to pull status anyway (if configured)\n" + ex.getMessage());

        UserWorkflowResult<Pair<UserUR, Boolean>> updated = new UserWorkflowResult<>(
                Pair.of(userUR, false),
                new PropagationByResource<>(),
                new PropagationByResource<>(),
                new HashSet<>());
        sendMessage("direct:userInPull", updated, props);
        exchange = pollingConsumer.receive();
    }

    return exchange.getIn().getBody(Pair.class);
}