-
1. Re: How to communicate (Consume & produce msgs) with remote HornetQ which is embedded with JBoss 7 ?
gaohoward Jun 3, 2013 2:48 AM (in response to ajinkya.bambal)1 of 1 people found this helpfulHornetQ supports full JMS spec, so you can write your message listeners just like any standard JMS applications. (take a look at the many jms examples that comes with HornetQ download).
Howard
-
2. Re: How to communicate (Consume & produce msgs) with remote HornetQ which is embedded with JBoss 7 ?
ajinkya.bambal Jun 3, 2013 3:18 AM (in response to gaohoward)Thnx Yong Hao Gan,
but previously , I was using HornetQ as a standalone server where to look up resources (Queue , CF) i.e for JNDI lookup, I was using IP address and port no ......
but now I hv embedded HornetQ with Jboss7 (i.e I am using HornetQ as a service) , Now in this case How do JMS Listeners which are running remotely & listening to hornetQ will do JNDI lookup for the hornetQ resources..I hope my question is clear...
-
3. Re: How to communicate (Consume & produce msgs) with remote HornetQ which is embedded with JBoss 7 ?
gaohoward Jun 3, 2013 3:27 AM (in response to ajinkya.bambal)1 of 1 people found this helpfulWith HornetQ in AS7 you still can use JNDI, only the context properties and naming convention may be different. For example:
Properties env = new Properties(); env.put("java.naming.factory.initial", "org.jboss.naming.remote.client.InitialContextFactory"); env.put("java.naming.provider.url", "remote://localhost" + ":4447"); Context context = new InitialContext(env); ConnectionFactory cf = (ConnectionFactory)context.lookup("jms/RemoteConnectionFactory"); if you have this connection factory entry configured:
<entries> <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/> </entries> Howard
-
4. Re: How to communicate (Consume & produce msgs) with remote HornetQ which is embedded with JBoss 7 ?
ajinkya.bambal Jun 3, 2013 3:54 AM (in response to gaohoward)Thnx Yong Hao Gan,
I have also deployed an application i.e EAR files on my AS (JBoss 7 where hornet is running as a service in AS) . Now my EAR contains MDB's so do I use same JNDI lookup what u mentioned above ?
Now the scenario is,
from the EAR , one java program is sending msg to hornetQ & I want another standalone java application (which is running remotely ) should listen to hornetq & receive this msg ...
After processing the message it should send reply back to hornetQ and MDB's which are present locally for EAR appication should receive the response msg.....
-
5. Re: How to communicate (Consume & produce msgs) with remote HornetQ which is embedded with JBoss 7 ?
gaohoward Jun 3, 2013 4:20 AM (in response to ajinkya.bambal)EAR/MDB is different. I'd suggest you download the AS7/quickstart example set and take a look at them, esp the helloworld-mdb one.
-
6. Re: How to communicate (Consume & produce msgs) with remote HornetQ which is embedded with JBoss 7 ?
ajinkya.bambal Jun 17, 2013 1:44 AM (in response to gaohoward)Hi Yong,
Yong Hao Gao wrote:
With HornetQ in AS7 you still can use JNDI, only the context properties and naming convention may be different. For example:
Properties env = new Properties(); env.put("java.naming.factory.initial", "org.jboss.naming.remote.client.InitialContextFactory"); env.put("java.naming.provider.url", "remote://localhost" + ":4447"); Context context = new InitialContext(env); ConnectionFactory cf = (ConnectionFactory)context.lookup("jms/RemoteConnectionFactory"); if you have this connection factory entry configured:
<entries> <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/> </entries> Howard
According to your suggestion , I wrote following JNDI properties for my remote listener,
Following is my code snippest,
void getInitialContext() throws NamingException
{
java.util.Properties p = new java.util.Properties();
p.put("javax.naming.Context.INITIAL_CONTEXT_FACTORY", "org.jboss.naming.remote.client.InitialContextFactory");
p.put("javax.naming.Context.PROVIDER_URL", "remote://localhost:4447");
InitialContext ic = new javax.naming.InitialContext(p);
ConnectionFactory cf = (ConnectionFactory) ic.lookup("jms/RemoteConnectionFactory");
Destination destination = (Destination) ic.lookup("jms/queue/test");
Connection connection = cf.createConnection();
Session session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
connection.start();
}
but I am facing Exception as,
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at QueueReceiver.connectAndCreateSession(QueueReceiver.java:61)
at QueueReceiver.main(QueueReceiver.java:23)
...
plz help me out....olz let me know where im getting wrong.....
thnx....
-
7. Re: How to communicate (Consume & produce msgs) with remote HornetQ which is embedded with JBoss 7 ?
gaohoward Jun 17, 2013 6:55 AM (in response to ajinkya.bambal)p.put("javax.naming.Context.INITIAL_CONTEXT_FACTORY", "org.jboss.naming.remote.client.InitialContextFactory");
p.put("javax.naming.Context.PROVIDER_URL", "remote://localhost:4447");
Hi ,
You don't need to quote the property keys, what you need is:
p.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
p.put(javax.naming.Context.PROVIDER_URL, "remote://localhost:4447");
-
8. Re: How to communicate (Consume & produce msgs) with remote HornetQ which is embedded with JBoss 7 ?
ajinkya.bambal Jun 19, 2013 12:31 AM (in response to gaohoward)Hi Yong,
Thnks for quick reply..
Yong Hao Gao wrote:
p.put("javax.naming.Context.INITIAL_CONTEXT_FACTORY", "org.jboss.naming.remote.client.InitialContextFactory");
p.put("javax.naming.Context.PROVIDER_URL", "remote://localhost:4447");
Hi ,
You don't need to quote the property keys, what you need is:
p.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
p.put(javax.naming.Context.PROVIDER_URL, "remote://localhost:4447");
I removed the quote, But Now I am getting exception as,
javax.naming.NoInitialContextException: Cannot instantiate class: org.jboss.naming.remote.client.InitialContextFactory [Root exception is java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at QueueReceiver.getInitialContext(QueueReceiver.java:55)
at QueueReceiver.main(QueueReceiver.java:22)
Caused by: java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
... 5 more
And I have added jboss-client.jar in jboss-HOME/bin/client directory....but still problem persist...:(
-
9. Re: How to communicate (Consume & produce msgs) with remote HornetQ which is embedded with JBoss 7 ?
ajinkya.bambal Jun 19, 2013 12:49 AM (in response to ajinkya.bambal)Hi Yong,
Previous issue has resolved but I hv got new exception as,
javax.naming.NamingException: Failed to create remoting connection [Root exception is java.util.ServiceConfigurationError: org.xnio.XnioProvider: Provider org.xnio.nio.NioXnioProvider could not be instantiated: java.lang.NoSuchMethodError: org.jboss.logging.Logger.tracef(Ljava/lang/String;Ljava/lang/Object;)V]
at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:36)
at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:121)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at QueueReceiver.getInitialContext(QueueReceiver.java:55)
at QueueReceiver.main(QueueReceiver.java:22)
Caused by: java.util.ServiceConfigurationError: org.xnio.XnioProvider: Provider org.xnio.nio.NioXnioProvider could not be instantiated: java.lang.NoSuchMethodError: org.jboss.logging.Logger.tracef(Ljava/lang/String;Ljava/lang/Object;)V
at java.util.ServiceLoader.fail(ServiceLoader.java:207)
at java.util.ServiceLoader.access$100(ServiceLoader.java:164)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:353)
at java.util.ServiceLoader$1.next(ServiceLoader.java:421)
at org.xnio.Xnio.doGetInstance(Xnio.java:187)
at org.xnio.Xnio.getInstance(Xnio.java:146)
at org.jboss.remoting3.Remoting.createEndpoint(Remoting.java:73)
at org.jboss.naming.remote.client.EndpointCache.get(EndpointCache.java:44)
at org.jboss.naming.remote.client.InitialContextFactory.createEndpoint(InitialContextFactory.java:193)
at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateEndpoint(InitialContextFactory.java:174)
at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:138)
at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:104)
... 6 more
Caused by: java.lang.NoSuchMethodError: org.jboss.logging.Logger.tracef(Ljava/lang/String;Ljava/lang/Object;)V
at org.xnio.nio.NioXnio.<init>(NioXnio.java:76)
at org.xnio.nio.NioXnioProvider.<clinit>(NioXnioProvider.java:34)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:345)
... 15 more
I have added new jboss client jar but still problem occured....