[英]Multiple JChannels in one cluster
I thought that it is easily possible to have multiple JChannels (with different names) in the same cluster. 我认为很容易在同一集群中具有多个JChannel(名称不同)。 I have to following setup:
我必须进行以下设置:
@Singleton
public class ChannelOne extends ReceiverAdapter
{
JChannel channel;
public void start()
{
channel = new JChannel();
channel.setReceiver(this);
channel.connect("ChannelOne");
}
public void receive(Message msg)
{
DataObject data = (DataObject) msg.getObject();
log.debug("JGroups: Message received event received: " + data.eventData);
}
public void send(DataObject data)
{
Message msg = new Message(null, null, data);
log.debug("JGroups: send: " + data.eventData);
channel.send(msg);
}
public void viewAccepted(View new_view)
{
log.debug("JGroups: View accepted: " + new_view);
}
}
And my JGroups configuration is the following (it is used on openshift, where we cannot use UDP! - How to open a JChannel (JGroups) using Openshift Wildfly 8 Cartridge ) 我的JGroups配置如下(在openshift上使用,无法使用UDP!- 如何使用Openshift Wildfly 8 Cartridge打开JChannel(JGroups) )
<config xmlns="urn:org:jgroups"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/JGroups-3.3.xsd">
<TCP
external_addr="${env.OPENSHIFT_GEAR_DNS}"
external_port="${env.OPENSHIFT_WILDFLY_CLUSTER_PROXY_PORT}"
bind_port="${env.OPENSHIFT_WILDFLY_CLUSTER_PORT}"
bind_addr="${env.OPENSHIFT_WILDFLY_IP}"
defer_client_bind_addr="true"
enable_diagnostics="false"/>
<TCPPING timeout="3000"
initial_hosts="${env.OPENSHIFT_WILDFLY_CLUSTER}"
port_range="0"
num_initial_members="1"/>
<MERGE2/>
<FD/>
<VERIFY_SUSPECT/>
<BARRIER/>
<pbcast.NAKACK2
use_mcast_xmit="false"/>
<UNICAST3/>
<pbcast.STABLE/>
<pbcast.GMS/>
<MFC/>
<FRAG2/>
</config>
Now assume that we have not only a ChannelOne but also a ChannelTwo Singleton with the goal to seperate events by their usage. 现在假设我们不仅有一个ChannelOne,而且还有一个ChannelTwo Singleton,其目标是通过事件的使用来区分事件。
If I do so, I observe that the messages are not all received correctly. 如果这样做,我发现消息没有全部正确接收。 There seems to be a mix between the two channels.
这两个渠道之间似乎混在一起。 I have a plenty of warnings in the log that messages have been dropped.
我在日志中有很多警告,指出已删除邮件。
What do I understand wrong in this concept of Channels? 我对这个频道概念有何误解?
A channel is an endpoint into a cluster. 通道是群集的端点。 If you have different applications using different clusters you need to separate the clusters, or else the apps will receive each other's messages.
如果您有使用不同群集的不同应用程序,则需要将群集分开,否则这些应用程序将收到彼此的消息。
To do this, pick different ports ( external_port
, bind_port
) for the different clusters. 为此,
bind_port
为不同的群集选择不同的端口( external_port
, bind_port
)。
This is the "ping" mechanism we use with WF/EAP on OpenShift: 这是我们在OpenShift上与WF / EAP一起使用的“ ping”机制:
Should be easy to configure and use. 应该易于配置和使用。
Note: authorization must be granted to the service account the pod is running under to be allowed to access Kubernetes' REST api. 注意:必须将权限授予运行Pod的服务帐户,以允许其访问Kubernetes的REST api。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.