Search in sources :

Example 51 with PollingConsumer

use of org.apache.camel.PollingConsumer in project syncope by apache.

the class CamelAnyObjectProvisioningManager method create.

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public Pair<String, List<PropagationStatus>> create(final AnyObjectTO anyObjectTO, final Set<String> excludedResources, final boolean nullPriorityAsync) {
    PollingConsumer pollingConsumer = getConsumer("direct:createAnyObjectPort");
    Map<String, Object> props = new HashMap<>();
    props.put("excludedResources", excludedResources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    sendMessage("direct:createAnyObject", anyObjectTO, 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);
}
Also used : Exchange(org.apache.camel.Exchange) PollingConsumer(org.apache.camel.PollingConsumer) HashMap(java.util.HashMap) Transactional(org.springframework.transaction.annotation.Transactional)

Example 52 with PollingConsumer

use of org.apache.camel.PollingConsumer in project syncope by apache.

the class CamelGroupProvisioningManager method create.

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public Pair<String, List<PropagationStatus>> create(final GroupTO groupTO, final Map<String, String> groupOwnerMap, final Set<String> excludedResources, final boolean nullPriorityAsync) {
    PollingConsumer pollingConsumer = getConsumer("direct:createGroupInPullPort");
    Map<String, Object> props = new HashMap<>();
    props.put("groupOwnerMap", groupOwnerMap);
    props.put("excludedResources", excludedResources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    sendMessage("direct:createGroupInPull", groupTO, 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);
}
Also used : Exchange(org.apache.camel.Exchange) PollingConsumer(org.apache.camel.PollingConsumer) HashMap(java.util.HashMap) Transactional(org.springframework.transaction.annotation.Transactional)

Example 53 with PollingConsumer

use of org.apache.camel.PollingConsumer in project syncope by apache.

the class CamelGroupProvisioningManager method update.

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public Pair<GroupPatch, List<PropagationStatus>> update(final GroupPatch anyPatch, final Set<String> excludedResources, final boolean nullPriorityAsync) {
    PollingConsumer pollingConsumer = getConsumer("direct:updateGroupPort");
    Map<String, Object> props = new HashMap<>();
    props.put("excludedResources", excludedResources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    sendMessage("direct:updateGroup", 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);
}
Also used : Exchange(org.apache.camel.Exchange) PollingConsumer(org.apache.camel.PollingConsumer) HashMap(java.util.HashMap) Transactional(org.springframework.transaction.annotation.Transactional)

Example 54 with PollingConsumer

use of org.apache.camel.PollingConsumer in project syncope by apache.

the class CamelGroupProvisioningManager method provision.

@Override
@SuppressWarnings("unchecked")
public List<PropagationStatus> provision(final String key, final Collection<String> resources, final boolean nullPriorityAsync) {
    PollingConsumer pollingConsumer = getConsumer("direct:provisionGroupPort");
    Map<String, Object> props = new HashMap<>();
    props.put("resources", resources);
    props.put("nullPriorityAsync", nullPriorityAsync);
    sendMessage("direct:provisionGroup", 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);
}
Also used : Exchange(org.apache.camel.Exchange) PollingConsumer(org.apache.camel.PollingConsumer) HashMap(java.util.HashMap)

Example 55 with PollingConsumer

use of org.apache.camel.PollingConsumer in project syncope by apache.

the class CamelGroupProvisioningManager method unlink.

@Override
public String unlink(final GroupPatch groupPatch) {
    PollingConsumer pollingConsumer = getConsumer("direct:unlinkGroupPort");
    sendMessage("direct:unlinkGroup", groupPatch);
    Exchange exchange = pollingConsumer.receive();
    if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
        throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
    }
    return exchange.getIn().getBody(GroupPatch.class).getKey();
}
Also used : Exchange(org.apache.camel.Exchange) PollingConsumer(org.apache.camel.PollingConsumer) GroupPatch(org.apache.syncope.common.lib.patch.GroupPatch)

Aggregations

PollingConsumer (org.apache.camel.PollingConsumer)73 Exchange (org.apache.camel.Exchange)41 Test (org.junit.Test)27 HashMap (java.util.HashMap)21 CamelContext (org.apache.camel.CamelContext)21 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)21 RouteBuilder (org.apache.camel.builder.RouteBuilder)19 Endpoint (org.apache.camel.Endpoint)10 Connection (javax.jms.Connection)9 Transactional (org.springframework.transaction.annotation.Transactional)9 ConnectionFactory (javax.jms.ConnectionFactory)7 JMSException (javax.jms.JMSException)7 MessageConversionException (org.springframework.jms.support.converter.MessageConversionException)5 ProducerTemplate (org.apache.camel.ProducerTemplate)4 WorkflowResult (org.apache.syncope.core.provisioning.api.WorkflowResult)4 Message (javax.jms.Message)3 Session (javax.jms.Session)3 TextMessage (javax.jms.TextMessage)3 ActiveMQTextMessage (org.apache.activemq.command.ActiveMQTextMessage)3 File (java.io.File)2