0

I am using ActiveMQ on a cluster of computers to send messages between java processes.

The cluster has a shared NFS mount accessible from all hosts.

I am running into problems with the following scenario:

  • host A creates a new file "/path/to/shared/nfs/xyz"
  • host A sends a message to host B: "process /path/to/shared/nfs/xyz"
  • host B receives the message, attempts to open the file
  • host B fails because NFS client has not yet noticed that a new file was previously created on A (race condition between ActiveMQ and the NFS protocol)

My solution is to add a loop into all message receivers that would wait up to 1 minute for the NFS to realize a new file was added.

This solution however seems unclean. What would be a good way of solving this? Do you know of any enterprise integration design patterns that apply?

4

1 回答 1

2

另一个想法是让主机 B 成为一个文件轮询使用者,它会拾取放置在“/path/to/shared/nfs/xyz”中的任何内容并处理它……这样你就不需要来自 A 的任何消息到 B 来启动它,只是文件的存在。

您仍然可以轻松地使用Apache Camel 的文件组件之类的东西...

from("file://path/to/shared/nfs/xyz").to(...);
于 2012-10-26T20:30:27.567 回答