1

以下のように 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 に答える