users@jms-spec.java.net

[jms-spec users] Re: Confusion about JMSProducer methods and CDI

From: Matthew White <WHITEMAT_at_uk.ibm.com>
Date: Tue, 17 Jun 2014 12:24:14 +0100

Hello;

The producer issue appears to be a defect; the time-to-live is a property
of the producer not the context so why would it be carried over?

Regards, Matthew.

Matthew White
WebSphere MQ JMS Technical Lead
Office Location:
DE2B12
Mail Point 127
IBM United Kingdom Limited
Hursley Park
Winchester
Hampshire, SO21 2JN
(Internal:
247653
(External:
+44 (0)1962 817653
*Email:
WHITEMAT_at_uk.ibm.com
Lotus Notes:
Matthew White/UK/IBM_at_IBMGB
 
LinkedIn
About.me

 
"The wrong answers are the ones you go looking for when the right answers
stare you in the face"




From: Elias Ross <genman_at_noderunner.net>
To: users_at_jms-spec.java.net
Date: 05/06/2014 19:30
Subject: [jms-spec users] Confusion about JMSProducer methods and
CDI
Sent by: genericelias_at_gmail.com



I'm really confused by this because this code doesn't do what you might
expect:

JMSProducer p = JMSContext.createProducer();
p.setTimeToLive(1000);
p.send(...)
JMSProducer p2 = JMSContext.createProducer();
p2.send(...) // time to live is set to 1000 here!

The settings from JMSProducer p are carried over to p2.

What's the point of having two producers here? The JavaDoc says "new
producer" but in fact the settings are carried over from the old
producer object.

I was using HornetQ, but it looks like the reference implementation
does do the same thing, though, but to me it seems really unintuitive.
The JavaDocs state that JMSContext represents a connection and
session, and JMSContext represents a producer.

The RI has it as:

public class JMSContextImpl implements JMSContext, Traceable {
....
        MessageProducer messageProducer;

The other question I had was the scoping for CDI. For example:

@ApplicationScoped
public class MyClient {
   @Inject JMSContext context;
}

public class MyServlet extends HttpServlet {
   @Inject MyClient client;
}

Then JMSContext ends up being potentially shared between multiple
threads. I would expect the scoping of JMSContext to be request, not
@Dependent here.



Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number
741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU