-
1. Re: Clustered JMS Queue / Stateful EJB replication / remote lookup
jaikiran Mar 5, 2012 3:41 AM (in response to sixtdeu)sixtdeu wrote:
2.)
Next I would like to test the bean replication of a stateful EJB. I've no idea how to do this, what should I configure on the bean or server, how to do an remote jndi lookup (other than the "ejb:/....?stateful" method). Could anyone help me?See these chapters:
https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI
-
2. Re: Clustered JMS Queue / Stateful EJB replication / remote lookup
sixtdeu Mar 5, 2012 5:48 AM (in response to jaikiran)Thanks for your fast answer. I didn't see that you completed the "Clustered+EJBs" chapter yesterday... I'll try it out.
edit: It's working fine, thanks for this.
Could you say something to my other questions:
1. What to do if the server the message client is connected to dies? Is there any method to make the client lookup "node independent" e.g. over a multicast adress unique for all server nodes or must the client react if one node dies and do a reconnect to another node?
2. Is there any other method to do a remote lookup for an ejb? The "ejb:/...?stateful" method is specific to jboss. What about the global jndi names? Usually I don't need to alter my source code if I change the server e.g. from jboss to was or glassfish.
Thanks!
-
3. Re: Clustered JMS Queue / Stateful EJB replication / remote lookup
only1kairi Mar 5, 2012 9:36 AM (in response to sixtdeu)Hi sixtdeu
Would you mind providing the configuration you have in your domain.xml for your clustered queue and your mdb? I would like to have my queues clustered as well but I keep running into problem with my MDB connecting to the Queue. Here's my error.
WARN [org.hornetq.jms.server.recovery.HornetQXAResourceWrapper] Can't connect to any hornetq server on recovery [XARecoveryConfig [hornetQConnectionFactory=HornetQConnectionFactory [serverLocator=ServerLocatorImpl [initialConnectors=[org-hornetq-core-remoting-impl-invm-InVMConnectorFactory?server-id=0], discoveryGroupConfiguration=null], clientID=null, dupsOKBatchSize=1048576, transactionBatchSize=1048576, readOnly=false], username=null, password=null]]
Thanks in advance
Kai-
-
4. Re: Clustered JMS Queue / Stateful EJB replication / remote lookup
sixtdeu Mar 5, 2012 10:02 AM (in response to only1kairi)Hi Kairi,
I just added these two lines to the standard config:
<subsystem xmlns="urn:jboss:domain:messaging:1.1">
<hornetq-server>
<clustered>true</clustered>
<persistence-enabled>true</persistence-enabled><cluster-password>just_a_password</cluster-password>
<journal-file-size>102400</journal-file-size>
<journal-min-files>2</journal-min-files>After this you need a broadcast and discovery group and cluster-conn config:
<broadcast-groups>
<broadcast-group name="broadgroup">
<group-address>231.7.7.7</group-address>
<group-port>9876</group-port>
<broadcast-period>2000</broadcast-period>
<connector-ref>
netty
</connector-ref>
</broadcast-group>
</broadcast-groups><discovery-groups>
<discovery-group name="disgroup">
<group-address>231.7.7.7</group-address>
<group-port>9876</group-port>
<refresh-timeout>1000</refresh-timeout>
</discovery-group>
</discovery-groups><cluster-connections>
<cluster-connection name="my-cluster">
<address>jms</address>
<connector-ref>netty</connector-ref>
<retry-interval>500</retry-interval>
<use-duplicate-detection>true</use-duplicate-detection>
<forward-when-no-consumers>true</forward-when-no-consumers>
<max-hops>1</max-hops>
<discovery-group-ref discovery-group-name="disgroup"/>
</cluster-connection>
</cluster-connections>Now you need an application user which is a member of the group defined in <permission type="send" roles="guest"/>. You can just add him to the application-roles.properties file in the config folder.
From a standalone client the lookup seems like this:
String JBOSS_CONTEXT = "org.jboss.naming.remote.client.InitialContextFactory";
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, JBOSS_CONTEXT);
props.put(Context.PROVIDER_URL, "remote://yourServersIP:4447");
props.put(Context.SECURITY_PRINCIPAL, "appUsername");//needs an application user added using add-user.bat/sh -console-application
props.put(Context.SECURITY_CREDENTIALS, "appUserPass");
Context context = new InitialContext(props);
ConnectionFactory cf = (ConnectionFactory) context.lookup("jms/RemoteConnectionFactory");
Connection conn = cf.createConnection("appUsername", "appUserPass");
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination dest = (Destination) context.lookup("jms/queue/test");
MessageProducer prod = sess.createProducer(dest);I hope I didn't forget any important thing.
Best regards
Chris
-
5. Re: Clustered JMS Queue / Stateful EJB replication / remote lookup
sixtdeu Mar 5, 2012 10:07 AM (in response to sixtdeu)I forgot to say, that all these changes I made in <profile name="full-ha">...
-
6. Re: Clustered JMS Queue / Stateful EJB replication / remote lookup
only1kairi Mar 5, 2012 10:37 AM (in response to sixtdeu)Are you using the in-vm or netty Connection Factory jndi name in your MDB?
<jms-connection-factories> <connection-factory name="InVmConnectionFactory"> <connectors> <connector-ref connector-name="in-vm"/> </connectors> <entries> <entry name="java:/ConnectionFactory"/> </entries> </connection-factory> <connection-factory name="RemoteConnectionFactory"> <connectors> <connector-ref connector-name="netty"/> </connectors> <entries> <entry name="RemoteConnectionFactory"/> <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/> </entries> </connection-factory> <pooled-connection-factory name="hornetq-ra"> <transaction mode="xa"/> <connectors> <connector-ref connector-name="in-vm"/> </connectors> <entries> <entry name="java:/JmsXA"/> </entries> </pooled-connection-factory> </jms-connection-factories> -
7. Re: Clustered JMS Queue / Stateful EJB replication / remote lookup
sixtdeu Mar 5, 2012 10:49 AM (in response to only1kairi)I'm using netty.
-
8. Re: Clustered JMS Queue / Stateful EJB replication / remote lookup
only1kairi Mar 5, 2012 11:34 AM (in response to sixtdeu)I was able to get the system to come on with no errors or exceptions with the configurations you suggested. However, the queue messages are still not being load balanced between the nodes. I am using the RemoteConnectionFactory to send the messages, maybe I should restart the second node?
-
9. Re: Clustered JMS Queue / Stateful EJB replication / remote lookup
sixtdeu Mar 5, 2012 11:42 AM (in response to only1kairi)A sample MDB could look like this:
@MessageDriven(name = "HelloWorldMDB", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/test"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })
public class HelloWorldMDB implements MessageListener {public void onMessage(Message rcvMessage) {
//do something
}
}Which profile do you use to deploy the MDB? My EAR is deployed on full-ha. The server nodes are defined on "other-server-group" (full-ha-profile).
-
10. Re: Clustered JMS Queue / Stateful EJB replication / remote lookup
only1kairi Mar 5, 2012 11:45 AM (in response to only1kairi)How did you connect your MDB to netty?
Did you reconfigure any of the information below differently?
<pooled-connection-factory name="hornetq-ra"> <transaction mode="xa"/> <connectors> <connector-ref connector-name="in-vm"/> </connectors> <entries> <entry name="java:/JmsXA"/> </entries> </pooled-connection-factory> </jms-connection-factories> @MessageDriven(name = "ESPQueueManagerMDB", activationConfig = {
@ActivationConfigProperty(propertyName = "maxSession", propertyValue = "25"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/EspQueue")})
Thanks
Kai-
-
11. Re: Clustered JMS Queue / Stateful EJB replication / remote lookup
only1kairi Mar 5, 2012 11:52 AM (in response to only1kairi)I am using the full-ha profile.
-
12. Re: Clustered JMS Queue / Stateful EJB replication / remote lookup
only1kairi Mar 5, 2012 11:53 AM (in response to only1kairi)I wish there was a logger that we could turn on for the jms service.
-
13. Re: Clustered JMS Queue / Stateful EJB replication / remote lookup
only1kairi Mar 5, 2012 12:13 PM (in response to only1kairi)What's weird, is that I am seeing the messages load balance itself on the queue within the same physical server box but the queues on the second machine are not seeing any activity.
-
14. Re: Clustered JMS Queue / Stateful EJB replication / remote lookup
rhusar Mar 5, 2012 1:05 PM (in response to only1kairi)Kairi Henry wrote:
I wish there was a logger that we could turn on for the jms service.
Take a look at logging subsystem, you can even configure this from the console.