Skip to main content
Skip table of contents

4.12 Tunneling Through Firewalls

Consider a scenario where client applications are protected by a corporate firewall and need to use the services of FioranoMQ server through SOCKS tunneling. The following code illustrates how the clients' applications, even when protected by firewalls, can access the services of the FioranoMQ server by tunneling through client side firewalls.

CODE
// This code fragment expects the args[] to contain
 // clientproxyName, clientProxyPort, FioranoMQ 9ServerAddress,
 // FioranoMQ 9Server Port. 
 public void sendData(String[] args)
 {
 try
 {
 why everything is codefirst... only the first line should be codefirst and remaining code.. here the codefirst should be :
 // This code fragment expects the args[] to contain
 and remain till the end of section it should be code.....//Initialize firewall Settings
 String proxyName = args[0];
 int proxyPort = Integer.parseInt (args[1]);
 //Initialize FioranoMQ 9 Server Settings
 String serverName = args[2];
 int serverPort = Integer.parseInt (args[3]); 
 // 1. Create the InitialContext Object used for
 // looking up JMS administered objects.
 // Set the Client Proxy Address/port.
 // The 1st argument is set to NULL to indicate
 // that there is no security parameter that has
 // been set. This parameter is set for
 // SSL Tunneling. 
 FioranoInitialContext ic = new FioranoInitialContext (); 
 // Set System property to indicate proxyHost and
 // proxy Port. All calls now get routed through
 // the SOCKS Server. 
 Properties property = System.getProperties();
 property.put ("socksProxyPort",""+proxyPort);
 property.put ("socksProxyHost",proxyName);
 System.setProperties (property); 
 // Bind the InitialContext to Server
 ic.bind (InetAddress.getByName(serverName),
 serverPort); 
 // Lookup Connection Factory and Topic names
 TopicConnectionFactory tcf =(TopicConnectionFactory) ic.lookup("primaryTCF");
 Topic topic = (Topic)ic.lookup("primaryTopic"); 
 // 4.2 Dispose the InitialContext resources
 //
 ic.dispose(); 
 // 2. Create and start a topic connection.
 System.out.println("Creating topic connection");
 TopicConnection tc = tcf.createTopicConnection();
 tc.start (); 
 // 3. Create a topic session on this connection.
 TopicSession ts = tc.createTopicSession(false,1); 
 // 4. Create a publisher for this topic.
 TopicPublisher tp = ts.createPublisher(topic);
 System.out.println ("Ready to publish messages :
 Enter Q to Quit..."); 
 // 5. Create a text message for use in the 'while'.
 // loop 
 TextMessage textmsg1 = ts.createTextMessage(); 
 // 6. Read in data from standard input and publish
 // it in a loop
 while (true)
 {
 BufferedReader br = new BufferedReader
 (new InputStreamReader(System.in), 1);
 System.out.print("Enter a Message to be
 published : ");
 String str = br.readLine();
 // Set and Publish the message
 textmsg4.setText(str);
 tp.publish(textmsg1);
 // Break out of this loop when done
 if (str.equalsIgnoreCase ("Q") )
 break;
 }
 System.out.println("Closing topic session and topic connection");
 ts.close();
 tc.close();
 }
 catch(Exception ex)
 {
 ex.printStackTrace();
 }
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.