When executing the following snippet of code I need an instance of GlassFish running on the local host otherwise it complains about endpoints not being defined. With another broker like ActiveMQ I simply do a lookup using a tcp:// ... url without an instance of ActiveMQ running on the local machine the client is running on.
How can I get this to work without having to have GlassFish running on the client machine?
Thanks, S.D.
public JMSTest()
{
Hashtable properties = new Hashtable(2);
properties.put(Context.PROVIDER_URL,"iiop://<remote ip address>:3701");
properties.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.appserv.naming.S1ASCtxFactory");
try
{
ctx = new InitialContext(properties);
}
catch (NamingException ex)
{
ex.printStackTrace();
}
}
public Object lookup(String name)
{
try
{
return ctx.lookup(name);
}
catch (NamingException ex)
{
ex.printStackTrace();
}
return null;
}
public static void main(String[] args)
{
JMSTest client = new JMSTest();
try
{
ConnectionFactory connectionFactory = (ConnectionFactory)client.lookup("jms/IncidentMessageFactory");
Queue queue = (Queue)client.lookup("jms/IncidentMessage");
javax.jms.Connection connection = connectionFactory.createConnection();
javax.jms.Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session.createProducer(queue);
TextMessage message = session.createTextMessage( incidentXML );
messageProducer.send( message );
}
catch(Exception ex)
{
ex.printStackTrace();
System.exit( 1 );
}
System.exit( 0 );
}
[Message sent by forum member 'samdoyle' (samdoyle)]
http://forums.java.net/jive/thread.jspa?messageID=211441