HornetQ: Remote client connect to HornetQ server which was running in VM
redbees Jul 30, 2014 3:55 AMI'm new in HornetQ, and I have tried to figure out for 2-3 days but hopeless.
Expected: 1 HornetQ stand-alone and sender (in VM)
2 clients as receivers (in real machine)
Sender:
Map<String, Object> connectionParams = new HashMap<String, Object>();
connectionParams.put(TransportConstants.HOST_PROP_NAME, "localhost");
connectionParams.put(TransportConstants.PORT_PROP_NAME, 5445);
TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams);
ConnectionFactory cf = new HornetQTopicConnectionFactory(false, transportConfiguration);
connection = cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
connection.start();
topic = HornetQJMSClient.createTopic("myTopic");
MessageProducer producer = session.createProducer(topic);
Receiver:
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.remote.client.InitialContextFactory");
p.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
p.put(Context.PROVIDER_URL, "remote://localhost:5445");
p.put(Context.SECURITY_PRINCIPAL, "admin");
p.put(Context.SECURITY_CREDENTIALS, "admin");
InitialContext context = new InitialContext(p);
ConnectionFactory factory = (ConnectionFactory)context.lookup("/ConnectFactory");
connection = (Connection) factory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
topic = (HornetQTopic) HornetQJMSClient.createTopic("myTopic");
MessageConsumer consumer = session.createConsumer(topic);
When I ./run.sh in VM (sender work fine)
then I run clients(receivers) in real machine but it cannot connect to HornetQ server (which is running in VM)
javax.naming.NamingException: Failed to connect to any server. Servers tried: [remote://localhost:5445]
at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:213)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:144)
at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:125)
at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:241)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)
at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at com.dtv.apg.hornetq.SubA.run(SubA.java:70)
at java.lang.Thread.run(Thread.java:722)
Thank you for any suggestion.