Skip to main content

Sending JMS to a Remote GlassFish Server problems

12 replies [Last post]
asherwin
Offline
Joined: 2008-04-15

I'm using Sun AppServer 9.1 and the default Sun Java System Message Queue 4.1

Problem space:
I need to send JMS messages to 1..n number of remote servers.

Now, I can send a JMS message to a remote JMS server using the "org.omg.CORBA.ORBInitialHost" and "org.omg.CORBA.ORBInitialPort" properties set as either JVM arguments with -D or programatically with System.setProperty(...).

Unfortunately, neither of these solutions are viable for sending messages to 1..n possible recipients. Workflows will be fired off from JMS Messages on multiple queues, meaning there can be any number of concurrent workflows attempting to send messages to any given destination JMS server.

Obviously, JVM args wont cut it. Also, System.setProperty() won't work, since there could be hundreds of simeltaneous threads that all need to send to different servers (I assume that System.setProperty() is JVM-wide, so if one thread sets a ORB host/port, all other threads will now be using that setting).

I can only assume that is why there is a InitialContex(Hashtable env) constructor that takes properties to use when creating a javax.jms.Context instance, but apparently the Sun impl of InitialContext wont use the CORBA Orb Host/Port settings set this way (or doesnt use any properties set this way? I don't know for sure).

Is there some other solution to this problem space using GlassFish/Sun Java System Message Queue 4.1?

Message was edited by: asherwin

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
chalava
Offline
Joined: 2008-03-13

Hi Alex,

If you want send messages from glassfish to another server like JBoss (vice versa).
What we have to provide for url and port in InitialContext .

Thanks
Nanda

janchj
Offline
Joined: 2008-12-03

Glassfish 9.1_02

There are 2 types of JNDI resources: Custom & External - Which one are you referring to?

What do you specify for the "Factory Class" if your resource type is:
1. Queue
2. Topic

hegyit
Offline
Joined: 2003-11-14

Hi, I am facing the same problem and have a few more questions.

> "com.sun.enterprise.naming.SerialInitContext" that
> wraps S1ASCtxFactory, and it looks like pretty much
> all it does it check the ORB properties and use them
> if they are set.
Does it mean you connected to Server A using com.sun.enterprise.naming.SerialInitContext?

> Create a JMS Resource (JNDI mapping only, dont bother
> creating a JMS Dest) that matches the JNDI on the
> remote server, i.e.:
How can you create a JNDI mapping but without a destination resource? Do you refer to it in your app deployed on ServerA using tags?

> Server B (Remote)
> jms_destA (JMS dest)
> jms/destA (JNDI resource)
>
> ServerA (Local)
> jms/remote/ConnFactory (w/ AddressList property set
> for the ServerB imq server)
> jms/destA JNDI (but no jms dest created)
>
> Now when you lookup jms/destA with
> jms/remote/ConnFactory on ServerA, it will lookup the
> remote server.
Do you set any properties like ORBInitialHost or ORBInitialPort in the initial context you open to ServerA?

What do you mean by lookup jms/destA with jms/remote/ConnFactory? Isn't jms/destA looked up as initialContext.lookup("jms/destA")? this is the normal way to look up destinations.

Thanks for any feedback or help. I'm fed up with this and also ask how can this be so non-trivial and under documented...

Tibor

agebee
Offline
Joined: 2008-07-15

Hi all,
has anybody solved that problem already or is there a workround / patch ?
I am facing the same problem with GlassFish v2 ur2 while I try to use the following Context:
Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory")
and the property "org.omg.CORBA.ORBInitialPort", "3700"
Any help is kindly appreciated.
Thanks

Alex Sherwin

What problem are you still facing?

If you are trying to send to a remote Glassfish server from within glassfish, it is easier to create a ConnectionFactory with the properties "AddressList", "Password" and "Username". You also need a local JMS resource (Queue/Topic) with the same JNDI name as the Queue/Topic on the remote server (but, you do not need to have a physical destination defined for IMQ locally).

Use the new ConnectionFactory and Queue JNDI that matches the remote Queues JNDI and it will be delivered to the remote IMQ server

Alex Sherwin
alex.sherwin@acadiasoft.com

-----Original Message-----
From: glassfish@javadesktop.org [mailto:glassfish@javadesktop.org]
Sent: Wednesday, September 24, 2008 1:27 AM
To: users@glassfish.dev.java.net
Subject: Re: Sending JMS to a Remote GlassFish Server problems

Hi all,
has anybody solved that problem already or is there a workround / patch ?
I am facing the same problem with GlassFish v2 ur2 while I try to use the following Context:
Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory")
and the property "org.omg.CORBA.ORBInitialPort", "3700"
Any help is kindly appreciated.
Thanks
[Message sent by forum member 'agebee' (agebee)]

http://forums.java.net/jive/thread.jspa?messageID=301199

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

agebee
Offline
Joined: 2008-07-15

Hi Alex,
I use the com.sun.jndi.fscontext.RefFSContextFactory in a Tomcat environment and it works fine.
The problem I had was Tomcat where I got runtime errors when using the com.sun.appserv.naming.S1ASCtxFactory.
So now I am fine with the abovementioned RefFSContextFactory and a .bindings file.
Nevertheless: Thanks for your suggestion of a 'remote solution'.
Harald

getaceres
Offline
Joined: 2007-05-28

I have the same problem. I try to access to a connection factory located in a remote host but it always tries to get it from localhost. I have the following set in the jvm options:

-Djava.naming.provider.url=iiop://:3700 -Djava.naming.factory.initial=com.sun.appserv.naming.S1ASCtxFactory -Dorg.omg.CORBA.ORBInitialHost= -Dorg.omg.CORBA.ORBInitialPort=3700

In the code I have this:

Hashtable env = new Hashtable();
env.put(Context.PROVIDER_URL, "iiop://:3700");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.appserv.naming.S1ASCtxFactory");
env.put("org.omg.CORBA.ORBInitialHost", "");
env.put("org.omg.CORBA.ORBInitialPort", "3700");

System.setProperty("org.omg.CORBA.ORBInitialHost", "");
System.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

Context ic = new InitialContext(env);

And even with all of that, I get this stack trace:

ADVERTENCIA: NAM1001: No Endpoints selected in com.sun.appserv.iiop.endpoints property. Using JNDI Provider URL iiop://:3700 instead
16-may-2008 11:46:06 com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl
ADVERTENCIA: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.0.1; port: 3700"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2690)

It first uses the remote server but then fails because it tries to access to localhost. Why? How can I send or receive JMS messages from a remote server?

asherwin
Offline
Joined: 2008-04-15

I've found out a lot more about this problem. If you go through the source of S1ASCtxFactory, you can see it doesn't look at the ORB properties. There is another factory class, "com.sun.enterprise.naming.SerialInitContext" that wraps S1ASCtxFactory, and it looks like pretty much all it does it check the ORB properties and use them if they are set.

So, if you use SerialInitContext it works. Great news, right? Wrong...

Now the problem is that it somewhere caches those settings, so you can only set them one time in that JVM instance. If you change them after using them the first time, the new property values will never get used.

What I've resorted to doing is probably what the designers intended. Create a local conn factory to use for remote connections, such as "jms/remote/ConnFactory" and set the "AddressList" property to the remote servers host:port (you can have a list. Check the docs for the conn factory properties)

Create a JMS Resource (JNDI mapping only, dont bother creating a JMS Dest) that matches the JNDI on the remote server, i.e.:

Server B (Remote)
jms_destA (JMS dest)
jms/destA (JNDI resource)

ServerA (Local)
jms/remote/ConnFactory (w/ AddressList property set for the ServerB imq server)
jms/destA JNDI (but no jms dest created)

Now when you lookup jms/destA with jms/remote/ConnFactory on ServerA, it will lookup the remote server.

However, if the remote server in unavailable... it will auto-create a jms dest based on its normal rules and send messages to the local queue :(

Thats the best i've been able to come up with...

ewernli
Offline
Joined: 2007-10-21

Isn't it possible to disable auto-creation of destination using property "imq.autocreate.queue" ?

http://docs.sun.com/source/819-0066/security.html#wp48118
http://docs.sun.com/source/819-0066/ref_broker_props.html#wp69049

asherwin
Offline
Joined: 2008-04-15

And now I've come accross this bug...

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6527987

How can something so fundamental not work the way it should? Setting as a JVM arg or a System property shouldn't be a solution at all in my opinion...

asherwin
Offline
Joined: 2008-04-15

I've tested this issue with the newer release of Sun AppServer 9.1_02 and Glassfish v2ur2 jars. The problem still occurs.

I see posts like this:
http://forum.java.sun.com/thread.jspa?threadID=5283256&tstart=0

Which are very recent, yet what they are posting code snippets of does not work for me whatsoever with Sun AppServer or Glassfish jars...

How can this be working for anyone while the above mentioned bug is still outstanding? Unless they are only using the default port of 3700...

asherwin
Offline
Joined: 2008-04-15

I know the the real solution should be to use the InitialContext(Hashtable env) constructor with the properties that I need, but going through the debug logging generated by the Sun impl classes, I can see that when using something such as:

env.put(Context.PROVIDER_URL, "iiop://127.0.0.1:6037");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.appserv.naming.S1ASCtxFactory");

That some properties are changed, in the logging statement "WARNING: NAM1001: No Endpoints selected in com.sun.appserv.iiop.endpoints property. Using JNDI Provider URL iiop://127.0.0.1:6037 instead"

But, setting the URL in this manner still doesnt work, and it seems that the ORB host/port poperties need to be used. Setting them similarly:

env.put("org.omg.CORBA.ORBInitialHost", "localhost");
env.put("org.omg.CORBA.ORBInitialPort", "6037");

Has no effect, shown in the logging statement "WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: localhost; port: 3700"

Setting the ORB host/port using System.setProperty or as a JVM arg does in fact change the host/port used, and works properly (but as mentioned before, these are not viable solutions)

Is this a bug with the current impl of the Sun InitialContext class?