akka.cluster 和持续交付问题
akka.cluster and persistence delivering issue
在我们的集群中,我们有四个节点组合:
- 2 个种子节点(后端)
- 1 名工人
- IIS 上的 1 个 WebAPI
集群加入,up 运行;当我向 webapi 发送 POST 时,:
- IIS加入集群
- API 收到 post 并使用 Tell
发送消息
- 消息被处理了两三次!
- 仅在 IIS 加入时发送的消息发生,以下消息工作正常
这是我的 IIS 配置:
<akka>
<hocon>
<![CDATA[
akka.loglevel = INFO
akka.log-config-on-start = off
akka.stdout-loglevel = INFO
akka.actor {
provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster"
deployment {
/TheProcess {
router = round-robin-group
routees.paths = ["/user/TheProcess"] # path of routee on each node
# nr-of-instances = 3 # max number of total routees
cluster {
enabled = on
allow-local-routees = off
use-role = TheProcess
}
}
}
debug {
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
akka.remote {
helios.tcp {
# transport-class = "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"
# applied-adapters = []
# transport-protocol = tcp
# public-hostname = "localhost"
# 0 or 46001-46010
port = 0
hostname = "localhost"
}
log-remote-lifecyclo-events = DEBUG
}
akka.cluster {
seed-nodes = [
"akka.tcp://ActorSystem@localhost:2551",
"akka.tcp://ActorSystem@localhost:2552"
]
roles = [TheSend]
# auto-down-unreachable-after = 10s
# how often should the node send out gossip information?
# gossip-interval = 1s
# discard incoming gossip messages if not handled within this duration
# gossip-time-to-live = 2s
}
# http://getakka.net/docs/persistence/at-least-once-delivery
akka.persistence.at-least-once-delivery.redeliver-interval = 300s
# akka.persistence.at-least-once-delivery.redelivery-burst-limit =
# akka.persistence.at-least-once-delivery.warn-after-number-of-unconfirmed-attempts =
akka.persistence.at-least-once-delivery.max-unconfirmed-messages = 1000000
akka.persistence.journal.plugin = "akka.persistence.journal.sql-server"
akka.persistence.journal.publish-plugin-commands = on
akka.persistence.journal.sql-server {
class = "Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer"
plugin-dispatcher = "akka.actor.default-dispatcher"
table-name = EventJournal
schema-name = dbo
auto-initialize = on
connection-string-name = "AkkaPersistence"
refresh-interval = 1s
connection-timeout = 30s
timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"
metadata-table-name = Metadata
}
akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.sql-server""
akka.persistence.snapshot-store.sql-server {
class = "Akka.Persistence.SqlServer.Snapshot.SqlServerSnapshotStore, Akka.Persistence.SqlServer"
plugin-dispatcher = ""akka.actor.default-dispatcher""
connection-string-name = "AkkaPersistence"
schema-name = dbo
table-name = SnapshotStore
auto-initialize = on
}
]]>
</hocon>
这是我的后端配置:
<hocon>
<![CDATA[
akka.loglevel = INFO
akka.log-config-on-start = on
akka.stdout-loglevel = INFO
akka.actor {
provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster"
debug {
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
akka.remote {
helios.tcp {
# transport-class = "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"
# applied-adapters = []
# transport-protocol = tcp
# public-hostname = "localhost"
#
# seed-node ports 2551 and 2552
# non-seed-node port 0 or 46001-46010
port = 2551
hostname = "localhost"
}
log-remote-lifecyclo-events = INFO
}
akka.cluster {
seed-nodes = [
"akka.tcp://ActorSystem@localhost:2551",
"akka.tcp://ActorSystem@localhost:2552"
]
roles = [TheProcess]
# auto-down-unreachable-after = 10s
}
]]>
</hocon>
我认为问题与 akka 持久性有关,问题是什么?
终于解决了,必须按照此处所述为每个 IIS 实例设置 persistenceId:
Identifiers
A persistent actor must have an identifier that doesn't
change across different actor incarnations. The identifier must be
defined with the PersistenceId method.
所以我放置了一个配置键,以便为每个特定的 IIS 实例设置正确的 persistenceId。
如果在执行 UnstashAll 的 ReceiveCommand 上也缺少 else,这会导致多次传送。
在我们的集群中,我们有四个节点组合:
- 2 个种子节点(后端)
- 1 名工人
- IIS 上的 1 个 WebAPI
集群加入,up 运行;当我向 webapi 发送 POST 时,:
- IIS加入集群
- API 收到 post 并使用 Tell 发送消息
- 消息被处理了两三次!
- 仅在 IIS 加入时发送的消息发生,以下消息工作正常
这是我的 IIS 配置:
<akka>
<hocon>
<![CDATA[
akka.loglevel = INFO
akka.log-config-on-start = off
akka.stdout-loglevel = INFO
akka.actor {
provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster"
deployment {
/TheProcess {
router = round-robin-group
routees.paths = ["/user/TheProcess"] # path of routee on each node
# nr-of-instances = 3 # max number of total routees
cluster {
enabled = on
allow-local-routees = off
use-role = TheProcess
}
}
}
debug {
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
akka.remote {
helios.tcp {
# transport-class = "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"
# applied-adapters = []
# transport-protocol = tcp
# public-hostname = "localhost"
# 0 or 46001-46010
port = 0
hostname = "localhost"
}
log-remote-lifecyclo-events = DEBUG
}
akka.cluster {
seed-nodes = [
"akka.tcp://ActorSystem@localhost:2551",
"akka.tcp://ActorSystem@localhost:2552"
]
roles = [TheSend]
# auto-down-unreachable-after = 10s
# how often should the node send out gossip information?
# gossip-interval = 1s
# discard incoming gossip messages if not handled within this duration
# gossip-time-to-live = 2s
}
# http://getakka.net/docs/persistence/at-least-once-delivery
akka.persistence.at-least-once-delivery.redeliver-interval = 300s
# akka.persistence.at-least-once-delivery.redelivery-burst-limit =
# akka.persistence.at-least-once-delivery.warn-after-number-of-unconfirmed-attempts =
akka.persistence.at-least-once-delivery.max-unconfirmed-messages = 1000000
akka.persistence.journal.plugin = "akka.persistence.journal.sql-server"
akka.persistence.journal.publish-plugin-commands = on
akka.persistence.journal.sql-server {
class = "Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer"
plugin-dispatcher = "akka.actor.default-dispatcher"
table-name = EventJournal
schema-name = dbo
auto-initialize = on
connection-string-name = "AkkaPersistence"
refresh-interval = 1s
connection-timeout = 30s
timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"
metadata-table-name = Metadata
}
akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.sql-server""
akka.persistence.snapshot-store.sql-server {
class = "Akka.Persistence.SqlServer.Snapshot.SqlServerSnapshotStore, Akka.Persistence.SqlServer"
plugin-dispatcher = ""akka.actor.default-dispatcher""
connection-string-name = "AkkaPersistence"
schema-name = dbo
table-name = SnapshotStore
auto-initialize = on
}
]]>
</hocon>
这是我的后端配置:
<hocon>
<![CDATA[
akka.loglevel = INFO
akka.log-config-on-start = on
akka.stdout-loglevel = INFO
akka.actor {
provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster"
debug {
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
akka.remote {
helios.tcp {
# transport-class = "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"
# applied-adapters = []
# transport-protocol = tcp
# public-hostname = "localhost"
#
# seed-node ports 2551 and 2552
# non-seed-node port 0 or 46001-46010
port = 2551
hostname = "localhost"
}
log-remote-lifecyclo-events = INFO
}
akka.cluster {
seed-nodes = [
"akka.tcp://ActorSystem@localhost:2551",
"akka.tcp://ActorSystem@localhost:2552"
]
roles = [TheProcess]
# auto-down-unreachable-after = 10s
}
]]>
</hocon>
我认为问题与 akka 持久性有关,问题是什么?
终于解决了,必须按照此处所述为每个 IIS 实例设置 persistenceId:
Identifiers
A persistent actor must have an identifier that doesn't change across different actor incarnations. The identifier must be defined with the PersistenceId method.
所以我放置了一个配置键,以便为每个特定的 IIS 实例设置正确的 persistenceId。
如果在执行 UnstashAll 的 ReceiveCommand 上也缺少 else,这会导致多次传送。