Package org.apache.servicemix.drools.model

Examples of org.apache.servicemix.drools.model.JbiHelper


    protected WorkingMemory createWorkingMemory(MessageExchange exchange) throws Exception {
        return ruleBase.newWorkingMemory();
    }

    protected void populateWorkingMemory(WorkingMemory memory, MessageExchange exchange) throws Exception {
        memory.setGlobal("jbi", new JbiHelper(this, exchange, memory));
        if (globals != null) {
            for (Map.Entry<String, Object> e : globals.entrySet()) {
                memory.setGlobal(e.getKey(), e.getValue());
            }
        }
View Full Code Here


     * Handle a consumer exchange
     */
    private void handleConsumerExchange(MessageExchange exchange)
        throws MessagingException {
        String correlation = (String) exchange.getProperty(DroolsComponent.DROOLS_CORRELATION_ID);
        JbiHelper helper = pending.get(correlation);
        if (helper != null) {
            MessageExchange original = helper.getExchange()
                    .getInternalExchange();
            if (exchange.getStatus() == ExchangeStatus.DONE) {
                done(original);
            } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
                fail(original, exchange.getError());
            } else {
                if (exchange.getFault() != null) {
                    MessageUtil.transferFaultToFault(exchange, original);
                } else {
                    MessageUtil.transferOutToOut(exchange, original);
                }
                send(original);
            }
            // update the rule engine's working memory to trigger post-done
            // rules
            helper.update();
        } else {
            logger.debug("No pending exchange found for "
                    + correlation
                    + ", no additional rules will be triggered");
        }
View Full Code Here

        }
    }

    protected void drools(MessageExchange exchange) throws Exception {
        WorkingMemory memory = createWorkingMemory(exchange);
        JbiHelper helper = populateWorkingMemory(memory, exchange);
        pending.put(exchange.getExchangeId(), helper);
        memory.fireAllRules();

        if (helper.getRulesFired() < 1) {
            fail(exchange, new Exception("No rules have handled the exchange. Check your rule base."));
        } else {
          //a rule was triggered and the message has been answered or faulted by the drools endpoint
            if (helper.isExchangeHandled()) {
                pending.remove(exchange);
            }

        }
    }
View Full Code Here

    protected WorkingMemory createWorkingMemory(MessageExchange exchange) throws Exception {
        return ruleBase.newWorkingMemory();
    }

    protected JbiHelper populateWorkingMemory(WorkingMemory memory, MessageExchange exchange) throws Exception {
        JbiHelper helper = new JbiHelper(this, exchange, memory);
        memory.setGlobal("jbi", helper);
        if (assertedObjects != null) {
            for (Object o : assertedObjects) {
                memory.assertObject(o);
            }
View Full Code Here

    protected void postProcess(MessageExchange exchange, WorkingMemory memory) throws Exception {
        if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
            String uri = getDefaultRouteURI();
            if (uri != null) {
                JbiHelper helper = (JbiHelper) memory.getGlobal("jbi");
                helper.route(uri);
            }
        }
        if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
            fail(exchange, new Exception("No rules have handled the exchange. Check your rule base."));
        }
View Full Code Here

    protected WorkingMemory createWorkingMemory(MessageExchange exchange) throws Exception {
        return ruleBase.newWorkingMemory();
    }

    protected void populateWorkingMemory(WorkingMemory memory, MessageExchange exchange) throws Exception {
        memory.setGlobal("jbi", new JbiHelper(this, exchange, memory));
        if (assertedObjects != null) {
            for (Object o : assertedObjects) {
                memory.assertObject(o);
            }
        }
View Full Code Here

        WorkingMemory memory = ruleBase.newWorkingMemory();
        return memory;
    }

    protected void populateWorkingMemory(WorkingMemory memory, MessageExchange exchange) throws Exception {
        memory.setGlobal("jbi", new JbiHelper(this, exchange, memory));
    }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.drools.model.JbiHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.