Embedded HornetQ server and client in peer to peer network
jfsherwoodiii Sep 29, 2009 11:16 PMThis is my first post to this forum, so I would appreciate comments about the post style, etc., so I can be easy to understand.
I am trying to implement a network of peer nodes, each of which can serve information and request information from each other, including very large file streams.
I intend to use secure, persistent messaging, with transactions, all implemented in core classes, but I am just now trying
to implement basic communications. I am {HornetQ, JBoss, JMS}-naive. HornetQ appears to be the perfect platform for me but...
My question is this: is there more complete Javadoc for the whole project? Classes do not have any commentary about the class itself, and most methods have absolutely no doc at all.
I am trying to configure and instantiate a HornetQ Server in each node (using what I can glean from the embedded example code and the users manual), and then set up a client session which can connect to any of the other node server instances using netty transport.
I have a small set of basic messages (POJOs) for registering nodes with each other, etc. I believe that I need to implement a MessageConsumer
on both server and client sides to receive and decode my messages and the responses.
I am getting exceptions when I try to start up a session for either the server or the client.:
Here is the server configuration and startup, which appears to be OK, but I am not sure.
====================================================
TransportConfiguration nettyAcceptorConfig = null;
TransportConfiguration nettyConnectorConfig = null;
try {
nettyAcceptorConfig = new TransportConfiguration(
NettyAcceptorFactory.class.getName());
Map<String, Object> connectionParams = nettyAcceptorConfig.getParams();
connectionParams.put(TransportConstants.PORT_PROP_NAME, this.serverPort);
/**
* TODO write the code that figures out what the local host name is
* and use it instead of localhost so remote nodes can connect!
*/
//this.realHostName = "localhost";
connectionParams.put(TransportConstants.HOST_PROP_NAME, this.realHostName);
ConfigurationImpl serverConfig = new ConfigurationImpl();
serverConfig.setPersistenceEnabled(false);
serverConfig.setSecurityEnabled(false);
serverConfig.setClustered(false);
serverConfig.setManagementClusterPassword("clusterManagement");
serverConfig.getAcceptorConfigurations().add(nettyAcceptorConfig);
// Start up the server for this node.
this.server = HornetQ.newHornetQServer(serverConfig);
this.server.start();
}
catch (Exception e)
{
System.out.println("Exception from starting server on node " + this.nodeName);
}
Next, I try to set up the client session before I send out a registration packet.
try {
final SimpleString clientQueueName = new SimpleString("incoming");
Queue incomingQueue = server.createQueue(clientQueueName, clientQueueName, null, false, false);
This throws an exception immediately -
logger says: INFO: HornetQ Server version 2.0.0.BETA5 (hornet-baby, 108) started
HornetQException[errorCode=101 message=null]
at org.hornetq.core.remoting.impl.wireformat.HornetQExceptionMessage.decodeBody(HornetQExceptionMessage.java:79)
at org.hornetq.core.remoting.impl.wireformat.PacketImpl.decode(PacketImpl.java:214)
at org.hornetq.core.remoting.impl.PacketDecoder.decode(PacketDecoder.java:435)
at org.hornetq.core.remoting.impl.RemotingConnectionImpl.bufferReceived(RemotingConnectionImpl.java:343)
...
...
/**
* Now create the structures needed for the client side so we can
* make requests to other nodes by address.
*/
nettyConnectorConfig = new TransportConfiguration(NettyConnectorFactory.class.getName());
Map<String, Object> connectionParams = nettyConnectorConfig.getParams();
connectionParams.put(TransportConstants.PORT_PROP_NAME, Node.MASTER_PORT);
connectionParams.put(TransportConstants.HOST_PROP_NAME, this.realHostName);
this.clientSessionFactory = new ClientSessionFactoryImpl(nettyConnectorConfig);
this.coreSession = this.clientSessionFactory.createSession(false, false, false);
coreSession.createQueue(incomingQueueName, incomingQueueName, false);
This throws the same exception - clearly there is a message being sent underneath the covers, but the decoders cannot figure it out. I haven't sent out my own custom message yet.
coreSession.close();
} catch (Exception e1) {
System.out.println ("Exception caught in " + this.nodeName + " while configuring the coreSession!!!");
e1.printStackTrace();
}
What steps I am missing, or obvious errors am I committing?
Frank Sherwood