HTTPS Sample Program

As we have seen previously, use of IIOP/HTTP tunnelling requires that the ORB's HTTP tunnel servlet is installed. Since this is a regular servlet, you can also configure it to use a HTTPS protocol. This example includes a modified web.xml deployment descriptor, which is configured for HTTPS.

To make things more interesting, this example includes a local and a remote broker. Local clients will send messages to the local broker, which in turn forwards messages to the remote broker using HTTPS. Clients on the remote system can retrieve messages from the remote broker using regular IIOP communication. This situation is depicted below:

The following steps are required to run this example:

  1. Deploy the ORB's tunnel servlet to an HTTPS URL. Please refer to the documentation of your servlet container for details. On Novell eXtend Application Server you must first add an SSL certificate and enable the SSL ports. You can use the supplied build.{sh,bat} script to build the tunnel WAR and the jb_tunnel_deploy_plan.xml deployment plan when running the SilverCmd utility:
       SilverCmd DeployWAR localhost:8080 silvermaster51 tunnel.war -f jb_tunnel_deploy_plan.xml -o -v 1 -U administrator -P admin
    
  2. Start a local JMS server, e.g. using the supplied msgsvc.local.properties configuration file. This broker must be configured with the msgsvc.router.targets property to ensure that messages are forwarded to the remove broker. Also, to ensure that tunnelling is used, the ORBHttpTunnelURL property must be specified on the command line, e.g.:
       jmqserv -props msgsvc.local.properties -J-DORBHttpTunnelURL=https://remote:443/orb/tunnel
    
  3. Start the remote JMS server as usual. Note that the msgsvc.name property for the remote broker must match the queue name in the local client. The remote broker should not be configured for HTTPS or tunnelling since it will merely receive messages from the ORB's HTTP tunnel.
  4. Finally, you can run the remote client on the remote system to retrieve the message that was routed from the local broker. Note that this is just a regular, local queue message consumer, which is not aware of any other broker than its local broker.
  5. 1 Running the Client

    Below is the source for the Local class. This is a queue sender, which sends a message to a remote queue via its local broker.

    package https;
                                                                               
    import javax.naming.InitialContext;
                                                                               
    import javax.jms.Queue;
    import javax.jms.Session;
    import javax.jms.TextMessage;
    import javax.jms.QueueSender;
    import javax.jms.QueueSession;
    import javax.jms.QueueReceiver;
    import javax.jms.QueueConnection;
    import javax.jms.QueueConnectionFactory;
                                                                               
    import com.sssw.jms.api.JMQQueue;
                                                                               
    /**
       This client will send a message to the local broker, which will route
       messages to a remote broker via HTTP/S.
     */
                                                                               
    public class Local
    {
        public static void main(String[] args) throws Exception
        {
        |   // get the initial context
        |   InitialContext ctx = new InitialContext();
        |                                                                      
        |   // get the queue object
        |   Queue queue = JMQQueue.getQueue("queue0@remote");
        |                                                                      
        |   // lookup the queue connection factory
        |   QueueConnectionFactory connFactory = (QueueConnectionFactory) ctx.
        |       lookup("queue/connectionFactory");
        |                                                                      
        |   // create a queue connection
        |   QueueConnection queueConn = connFactory.createQueueConnection();
        |                                                                      
        |   // start the connection
        |   queueConn.start();
        |                                                                      
        |   // create a queue session
        |   QueueSession queueSession = queueConn.createQueueSession(false,
        |       Session.AUTO_ACKNOWLEDGE);
        |                                                                      
        |   // create a queue sender
        |   QueueSender queueSender = queueSession.createSender(queue);
        |                                                                      
        |   // create a simple message to say "Hello"
        |   TextMessage message = queueSession.createTextMessage("Hello");
        |                                                                      
        |   // send the message
        |   queueSender.send(message);
        |                                                                      
        |   // close the queue connection
        |   queueConn.close();
        }
    }
    

    The remote client is also just a regular queue receiver, which connects to its local broker and receives a message from a queue:

    package https;
                                                                               
    import javax.naming.InitialContext;
                                                                               
    import javax.jms.Queue;
    import javax.jms.Session;
    import javax.jms.TextMessage;
    import javax.jms.QueueSender;
    import javax.jms.QueueSession;
    import javax.jms.QueueReceiver;
    import javax.jms.QueueConnection;
    import javax.jms.QueueConnectionFactory;
                                                                               
    /**
       This is a simple queue receiver.
     */
                                                                               
    public class Remote
    {
        public static void main(String[] args) throws Exception
        {
        |   // get the initial context
        |   InitialContext ctx = new InitialContext();
        |                                                                      
        |   // lookup the queue object
        |   Queue queue = (Queue) ctx.lookup("queue/queue0");
        |                                                                      
        |   // lookup the queue connection factory
        |   QueueConnectionFactory connFactory = (QueueConnectionFactory) ctx.
        |       lookup("queue/connectionFactory");
        |                                                                      
        |   // create a queue connection
        |   QueueConnection queueConn = connFactory.createQueueConnection();
        |                                                                      
        |   // start the connection
        |   queueConn.start();
        |                                                                      
        |   // create a queue session
        |   QueueSession queueSession = queueConn.createQueueSession(false,
        |       Session.AUTO_ACKNOWLEDGE);
        |                                                                      
        |   // create a queue receiver
        |   QueueReceiver queueReceiver = queueSession.createReceiver(queue);
        |                                                                      
        |   // receive a message
        |   TextMessage message = (TextMessage) queueReceiver.receive();
        |                                                                      
        |   // print the message
        |   System.out.println("received: " + message.getText());
        |                                                                      
        |   // close the queue connection
        |   queueConn.close();
        }
    }
    

    Back to top


Copyright © 2000-2003, Novell, Inc. All rights reserved.