可以使用C ++ Actor Framework以保证两个actor之间的消息排序吗?我在the manual找不到任何相关内容。
答案 0 :(得分:4)
如果您只有两个演员直接与进行通信,CAF会保证邮件按照发送顺序到达。只有多跳场景才会导致非确定性和消息重新排序。
<subsystem xmlns="urn:jboss:domain:datasources:1.2">
<datasources>
<datasource jta="false" jndi-name="java:jboss/datasources/ams" pool-name="OracleDS" enabled="true" use-ccm="false">
<connection-url>jdbc:oracle:thin:@rhhqrac01scant:1521/testingenv</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>oracle</driver>
<pool>
<min-pool-size>100</min-pool-size>
<max-pool-size>150</max-pool-size>
<prefill>true</prefill>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>ams</user-name>
<password>testpassword</password>
</security>
<validation>
<check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<set-tx-query-timeout>false</set-tx-query-timeout>
<blocking-timeout-millis>0</blocking-timeout-millis>
<idle-timeout-minutes>0</idle-timeout-minutes>
<query-timeout>0</query-timeout>
<use-try-lock>0</use-try-lock>
<allocation-retry>0</allocation-retry>
<allocation-retry-wait-millis>0</allocation-retry-wait-millis>
</timeout>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="oracle" module="com.oracle.ojdbc6">
<xa-datasource-class>oracle.jdbc.OracleDriver</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
在接收端,可以通过auto a = spawn(A);
self->send(a, "foo");
self->send(a, 42); // arrives always after "foo"
更改演员行为来更改消息处理顺序:
become
在上面的示例中,这将处理[=](int) {
self->become(
keep_behavior,
[=](const std::string&) {
self->unbecome();
}
);
}
消息之前的int
,即使它们在演员的邮箱中以相反的顺序到达。