Re: JMS connection issues

Tim Anderson <[email protected]> Mon, 30 Apr 2007 09:49:35 +1000
Newsgroups gmane.comp.java.openjms.user
Message-ID <[email protected]>
See inline:

Govinda Rao Deyyam wrote:

Hi Tim,

Thanks for
your reply. But still I am not
clear with your answers.

From your
first statement, you mean a new
connection object will be created but will be given to the same address
location …am I correct? How is it happening…how come the same
address will be given for the next object? You mean when we close the
Sender
program the connection object or address is not getting freed from the
memory….is
it? In this case if I run a Receiver program followed by Sender program
then
the same address should be given for the connection object created in
Receiver
program, but not happening. Who is allocating address and creating
connection
objects in this case?

Can you
explain the below question?

- Run a Sender program and
the address is abcd@abcd

- run a Receiver program
and the address is wxyz@xyz

- run the sender program
again but got the same address abcd@abcd

- run the sender program
again but got the same address wxyz@xyz

How am I
getting the same address for a
particular program …how is this mapping happening?

The @abcd and @xyz are derived from the hashCode() of the connection
object. The implementation of hashCode() used

is that provided by java.lang.Object.hashCode(). From the javadoc:

....

* As much as is reasonably practical, the hashCode method defined
by

* class <tt>Object</tt> does return distinct integers
for distinct

* objects. (This is typically implemented by converting the
internal

* address of the object into an integer

...

When you print the connection, the

Object.toString() method is being called, which simply does the
following:

return getClass().getName() + "@" + Integer.toHexString(hashCode());

your second
statement “If
you create an instance of another object prior to the creation of the
connection you should see the connection address change “is not clear
to me.

In my
examples I am running the sender
program second time means I am creating instance of the Sender freshly
who
creates a connection object. In this case there should be new address.

It is a new address. You are running in a different instance of the JVM
which just happens to allocate the object to the same internal address
in the new JVM.

My point was that if you changed the example programs to create another
object (anything, e,g new Long(0)) just prior to establishing the
connection,

the internal address of the connection object would be allocated to a
different address.

My second
issue: The firewall is closing
the connection after some inactive time (got confirmed). So we have
coded that
when ever we get a IllegalStateException or JMSException then creating
new
connection.

Thanks

Govind

----------

From:
openjms-user-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
[ mailto:openjms-user-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org ] On Behalf Of Tim Anderson

Sent: Saturday, April
28, 2007
12:22 PM

To:
[email protected]

Subject: Re:
[openjms-user] JMS
connection issues

See inline:

Govinda Rao Deyyam wrote:

Dear Users,

I have few queries on JMS
connection mechanism.

I have tried running the
example programs
(SimpleReceiver, SimpleSender) and found a strange thing.

I am printing the
connection object after getting the
connection from the factory object, code given below

QueueConnectionFactory
factory = (QueueConnectionFactory) context.lookup(factoryName);

QueueConnection connection = factory.createQueueConnection();

connection.start();

System.out.println("connection
is : "+connection);

But I am getting the same
connection object every
time when I run this program, given the results below. When the program
is
closed the objects instantiated by that program should also be freed
and when
we run the program next time new objects should be created but its not
happening in this case.

Example, same object is
getting returned for the
SenderProgram every time we run, same object getting returned for
Receiver program
every time we run. But the object is different for sender and receiver
programs
(have highlighted below).

Even if I close the
connection at the end of the
program the same object is getting returned when I run the program
second,
third..etc times.

Coud anyone please
explain this funda?

It just means that the connection object is being allocated to the same
address
each time the program is run.

If you create an instance of another object prior to the creation of
the
connection you should see the connection address change.

Sender
program:

E:\openjms-0.7.5\src\examples\openjms\examples\client\console>java
-cp %classpath% openjms.examples.client.console.SimpleSender -queue
request2

-mode
tcp
-jndiport 3055 -jndihost localhost -count 1

connection
is :
org.exolab.jms.client.JmsQueueConnection@6b7920

Publishing
org.exolab.jms.message.BytesMessageImpl@1cdeff

E:\openjms-0.7.5\src\examples\openjms\examples\client\console>java
-cp %classpath% openjms.examples.client.console.SimpleSender -queue
request2

-mode
tcp
-jndiport 3055 -jndihost localhost -count 1

connection
is :
org.exolab.jms.client.JmsQueueConnection@6b7920

Publishing
org.exolab.jms.message.BytesMessageImpl@1cdeff

E:\openjms-0.7.5\src\examples\openjms\examples\client\console>java
-cp %classpath% openjms.examples.client.console.SimpleSender -queue
request2

-mode
tcp
-jndiport 3055 -jndihost localhost -count 1

connection
is :
org.exolab.jms.client.JmsQueueConnection@6b7920

Publishing
org.exolab.jms.message.BytesMessageImpl@1cdeff

Receiver
Program:

E:\openjms-0.7.5\src\examples\openjms\examples\client\console>java
-cp %classpath% openjms.examples.client.console.SimpleReceiver -queue
request2

-mode
tcp
-jndiport 3055 -jndihost localhost -count 1

connection
is : org.exolab.jms.client.JmsQueueConnection@63b895

[1
of 1]
ObjectMessage JMSDeliveryMode=PERSISTENT, Priority=4,
JMSMessageID=ID:4734191357462726621

E:\openjms-0.7.5\src\examples\openjms\examples\client\console>java
-cp %classpath% openjms.examples.client.console.SimpleReceiver -queue
request2

-mode
tcp
-jndiport 3055 -jndihost localhost -count 1

connection
is : org.exolab.jms.client.JmsQueueConnection@63b895

[1
of 1]
ObjectMessage JMSDeliveryMode=PERSISTENT, Priority=4,
JMSMessageID=ID:2767882215716415820

E:\openjms-0.7.5\src\examples\openjms\examples\client\console>java
-cp %classpath% openjms.examples.client.console.SimpleReceiver -queue
request2

-mode
tcp
-jndiport 3055 -jndihost localhost -count 1

connection
is : org.exolab.jms.client.JmsQueueConnection@63b895

[1
of 1]
ObjectMessage JMSDeliveryMode=PERSISTENT, Priority=4,
JMSMessageID=ID:2767882215716415819

Q2. Is there
any possibility that JMS Server closes the connection after some
inactive time
(might be configurable)?

We are currently facing one problem where the connection is getting
closed
after some inactive time; we are suspecting that firewall is closing
this
connection, due to this we are getting illegalStateException when we
call any
operation on the connection object.

Whats the stack trace?

I appreciate the earliest
response.

Thanks & Regards

Govinda Rao

-Tim

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
openjms-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openjms-user