Reputation: 375
I am using JMS for getting the yahoo stock quotes asynchronously. I am creating JMSContext on the Producer side and I would like to use the same context of producer in consumer class as well. So when I make it public static then JMSContext is set to null. So can JMSContext be public and static? is there any other way to create the JMSContext in consumer? I am using netbeans to implement this task.
Upvotes: 0
Views: 61
Reputation: 1600
JMSContext is a Java object do can have what ever visibility you require for your application architecture. However read the JMS spec and you'll see that only 1 thread can use it at any one time. If you can enforce that in your application you can share the context, but if that doesn't make sense don't. It's not the JMS provider's job to enforce this threading restriction.
Upvotes: 1