简体   繁体   中英

JMS master/backup failover and failback configuration in Red Hat 7.2 EAP

We use Red Hat 7.2 EAP. We have X number of producers on Y number of machines sending messages to a JMS queue on a remote machine. The JMS queue is configured with a master and backup. X number of consumers on Y number of machines are consuming messages from the queue. The master and backup are on different machines. When the master goes down the producers and consumers need to continue processing messages. When the master comes back the consumers and producers need to fail back to the master.

I have read the documents published by Red Hat multiple times and best I can tell this should be easily done. However, when the consumers or producers start up and the master is down they do not have any way to connect to the backup queue. How do people handle this situation? Do the consumers and the producers have to be programed to know about the master and the backup and then try to connect to the backup if the master is not available or fails? The documentation leads me to believe that failover should be automatic in that the master communicates the backup location to client when it first attaches. If there are dozens of machines involved how does the configuration of the master/backup get to the consumers and producers? Do each of the consumer/producer nodes have to be configured with IP addresses? How do people make this type of thing scale?

We currently set up the producers and consumers to connect like this:

final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, PROVIDER_URL));
env.put(Context.SECURITY_PRINCIPAL, DEFAULT_USERNAME);
env.put(Context.SECURITY_CREDENTIALS, DEFAULT_PASSWORD);
namingContext = new InitialContext(env);

EAP uses a client/server JNDI implementation and JNDI connections are 100% independent of JMS connections. Since JNDI is the starting point for your connectivity with EAP you'll want to tackle that first. Typically an EAP JNDI URL looks something like this:

http-remoting://host:8080

Of course, if host is unavailable then the JNDI lookup will fail. You can address this in a number of ways the most basic of which is specifying multiple URLs, eg:

http-remoting://host1:8080,http-remoting://host2:8080

Other solutions involve dedicated load-balancers, DNS-based redirection, etc.

Once the JNDI lookup is complete you'll be able to establish a JMS connection. Assuming the server pair is set up correctly the connection will then fail-over and fail-back as needed.

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