2

我正在编写一个应用程序,它可以接收从不同来源进入系统的两种类型的事件。我想有一个上下文来处理它们中的每一个。请参阅下面的代码:

event MyEvent1{
  //stuff for context1
}

event MyEvent2{
  //stuff for context2
}

event Cascade{
  //PRIORITY stuff for context1 & 2
}

monitor Application{

  context parallel1 := context("E1processor");
  context parallel2 := context("E2processor");

  action onload{

    spawn handleE1() to parallel1; 
    spawn handleE2() to parallel2; 

    on all MyEvent1() as e {
      send e to parallel1;
    }

    on all MyEvent2() as e {
      send e to parallel2;
    }

  }//onload

  action handleE1( ){
      on all MyEvent1() as e1 {
        //do work, create and route CASCADE event
        route Cascade();
        //I want to do this!
        route Cascade() to parallel2; // < ----- ERROR
    }  

    on all Cascade(){
      //URGENT stuff
    }  

  }

  action handleE2(){
    on all MyEvent2() as e1 {
    }  

    on all Cascade(){
      //URGENT stuff
    }  
  }

}//Application

我的问题在于我希望将Cascade()事件推送到处理队列的前面,因为它是一个优先级。但是当我尝试执行以下操作时:

//do work, create and route CASCADE event
route Cascade(); //<--- Works
//I want to do this!
route Cascade() to parallel2; // < ----- ERROR

它给了我一个错误 - 我如何将事件作为优先级从一个上下文路由到另一个上下文?

4

1 回答 1

2

不幸的是,没有办法优先发送到另一个上下文。答案可能在本质上更具架构性 - 例如,级联处理是否可以简单地在主要上下文中完成?

于 2018-08-01T11:04:56.723 回答