简体   繁体   中英

Multiple JChannels in one cluster

I thought that it is easily possible to have multiple JChannels (with different names) in the same cluster. 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 )

<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.

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.

This is the "ping" mechanism we use with WF/EAP on OpenShift:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM