1

我在 tibco 上有一个队列。我正在尝试使用 drools 管道从队列中接收对象,如下所示。

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); 
String jmsRules ="jms.drl";
kbuilder.add(ResourceFactory.newClassPathResource(jmsRules, getClass()), ResourceType.DRL);

    if (kbuilder.hasErrors()) { 
        System.out.println("KBuilder has errors: " + kbuilder.getErrors()); 
        return; 
    } 

    KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); 
    kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); 
    StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); 
    KnowledgeRuntimeCommand insertStage = PipelineFactory.newStatefulKnowledgeSessionInsert(); 

    Action unwrapObjectStage = PipelineFactory.newJmsUnwrapMessageObject(); 
    unwrapObjectStage.setReceiver(insertStage); 

    Pipeline entry = PipelineFactory.newStatefulKnowledgeSessionPipeline(ksession); 
    entry.setReceiver(unwrapObjectStage); 

    Properties props = new Properties(); 

    props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.tibco.tibjms.naming.TibjmsInitialContextFactory"); 
    props.setProperty(Context.URL_PKG_PREFIXES, "com.tibco.tibjms.naming"); 
    props.setProperty(Context.PROVIDER_URL, "tibjmsnaming://10.6.8.21:7222"); 
    String destinationName = "DIAG1_vmware-ucs-1-v02_routing"; 

    Service messenger = PipelineFactory.newJmsMessenger(entry, props, destinationName, null); 
    messenger.start(); 
    ksession.fireAllRules(); 

    System.out.println("NUMBER OF FACTS INSERTED===>"+ksession.getFactCount());
    ksession.dispose(); 

    messenger.stop(); 

指定的队列(DIAG1_vmware-ucs-1-v02_routing)已经很少有对象。当我运行程序时,我得到以下异常。

Exception in thread "main" java.lang.RuntimeException: Unable to instantiate JmsFeeder
    at org.drools.runtime.pipeline.impl.JmsMessenger.<init>(JmsMessenger.java:63)
    at org.drools.runtime.pipeline.impl.JmsMessengerProviderImpl.newJmsMessenger(JmsMessengerProviderImpl.java:34)
    at org.drools.runtime.pipeline.PipelineFactory.newJmsMessenger(PipelineFactory.java:410)
    at com.sample.JMSPipelineSmooksDemo.go(JMSPipelineSmooksDemo.java:78)
    at com.sample.JMSPipelineSmooksDemo.main(JMSPipelineSmooksDemo.java:26)
Caused by: javax.naming.NameNotFoundException: Name not found: 'ConnectionFactory'
    at com.tibco.tibjms.naming.TibjmsContext.lookup(TibjmsContext.java:713)
    at com.tibco.tibjms.naming.TibjmsContext.lookup(TibjmsContext.java:489)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at org.drools.runtime.pipeline.impl.JmsMessenger.<init>(JmsMessenger.java:60)
    ... 4 more

请帮助我解决问题。

4

1 回答 1

1

Drools Pipeline 已弃用,请改用 Drools Camel。

于 2012-09-14T07:18:48.387 回答