This example shows you how to configure and use servlet transport over SSL with HornetQ.
Please refer to HornetQ Quickstart guide to install it in JBoss AS 5
In the configuration, the hornetq.example.keystore is the key store file holding client certificate. The hornetq.example.truststore is the file for server to hold trusted client certificates. They are pre-generated for illustration purpose1.
To deploy and start the server, type simply type ./build.sh deploy
(or build.bat deploy
on windows)from the example directory
Once the server has started type simply type ./build.sh run
(or build.bat run
on windows) to run the example.
To remove the new profile type simply type ./build.sh undeploy
(or build.bat undeploy
on windows).
jndi.properties
file in the directory config
initialContext = new InitialContext();
Queue queue = (Queue) initialContext.lookup("/queue/testQueue");
ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/TestServletConnectionFactory");
connection = cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session.createProducer(queue);
TextMessage message = session.createTextMessage("This is a text message");
messageProducer.send(message);
MessageConsumer messageConsumer = session.createConsumer(queue);
connection.start();
TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
finally
block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects
finally
{
if (initialContext != null)
{
initialContext.close();
}
if (connection != null)
{
connection.close();
}
}
keytool -genkey -keystore hornetq.example.keystore -storepass hornetqexample
keytool -export -keystore hornetq.example.keystore -file hornetq.cer
keytool -import -file hornetq.cer -keystore hornetq.example.truststore -storepass hornetqexample