2

For a JMS Point-to-Point producer, as per page 203 of Java EE 7 with GlassFish 4 Application Server, how is a remote lookup performed? I want to specify an ip address, 192.168.1.3, for the this producer:

output, with JNDI properties for a CORBA lookup logged to the console:

thufir@doge:~$ 
thufir@doge:~$ appclient -client NetBeansProjects/JMSPTPProducer/dist/JMSPTPProducer.jar 
Mar 08, 2015 4:58:18 AM org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 5.0.0.Final
Mar 08, 2015 4:58:18 AM com.sun.messaging.jms.ra.ResourceAdapter start
INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter: Version:  5.1  (Build 9-b) Compile:  July 29 2014 1229
Mar 08, 2015 4:58:18 AM com.sun.messaging.jms.ra.ResourceAdapter start
INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter starting: broker is REMOTE, connection mode is TCP
Mar 08, 2015 4:58:18 AM com.sun.messaging.jms.ra.ResourceAdapter start
INFO: MQJMSRA_RA1101: GlassFish MQ JMS Resource Adapter Started:REMOTE
{org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, Context.SECURITY_CREDENTIALS=pass123, org.omg.CORBA.ORBInitialHost=localhost, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, Context.SECURITY_PRINCIPAL=user1}
Sending the following message: Testing, 1, 2, 3. Can you hear me?
Sending the following message: Do you copy?
Sending the following message: Good bye!
thufir@doge:~$ 

Can I use the CORBA JNDI parameters, which are loaded from jndi.properties, and perhaps pass those values to ?

code:

package net.ensode.glassfishbook;

import static java.lang.StrictMath.log;
import javax.annotation.Resource;
import javax.jms.ConnectionFactory;
import javax.jms.JMSContext;
import javax.jms.JMSProducer;
import javax.jms.Queue;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class MessageSender {

    @Resource(mappedName = "jms/CrmConnectionFactory")
    //   @Resource(mappedName = "jms/GlassFishBookConnectionFactory")
    private static ConnectionFactory connectionFactory;

    @Resource(mappedName = "jms/CrmQueue")
    //   @Resource(mappedName = "jms/GlassFishBookQueue")
    private static Queue queue;

    public void produceMessages() throws NamingException {
        Context ctx = new InitialContext();
        System.out.println(ctx.getEnvironment().toString());
        JMSContext jmsContext = connectionFactory.createContext();
        JMSProducer jmsProducer = jmsContext.createProducer();
        String msg1 = "Testing, 1, 2, 3. Can you hear me?";
        String msg2 = "Do you copy?";
        String msg3 = "Good bye!";
        System.out.println("Sending the following message: "
                + msg1);
        jmsProducer.send(queue, msg1);
        System.out.println("Sending the following message: "
                + msg2);
        jmsProducer.send(queue, msg2);
        System.out.println("Sending the following message: "
                + msg3);
        jmsProducer.send(queue, msg3);
    }

    public static void main(String[] args) throws NamingException {
        new MessageSender().produceMessages();
    }
}

I've been looking through this text book, and googling, but, pardon, I don't know how remote JMS lookups are achieved.

While I really like this fluffy/frodo example, I'm not sure how to specify an ip address.

see also:

http://docs.oracle.com/cd/E19182-01/820-7853/ghyco/index.html

Community
  • 1
  • 1
Thufir
  • 8,216
  • 28
  • 125
  • 273

0 Answers0