Robert,
On 23/03/2011 15:05, Robert Weeks wrote:
> Hello again -
>
> Thanks again for the information - but I am still curious on this.
>
> In most of the GlassFish 3 books and using JMS within GlassFish 3 - there are references to using client ack without the information below - although not within MDB's of course. Sort of confusing - but the information below corresponds with what I am seeing.
Can you give any references to books etc that suggest differently? I'd be interested to see how they interpret the spec.
> Our app has OSGi bundles that utilize JMS for communicating, and we need to be able to keep a message on the queue if we can't process it immediately - thus the need for client ack.
>
> With this in mind, I then attempted to make the JMS resource remote so I can connect to it like a standalone within the bundle - but I need to have imq.jar to be available/exportable in felix. I wrapped imq.jar as a bundle just to get working - but curious if there was a way to have the imq classes resolvable to osgi bundles?
>
> I really don't want to go this course, would rather have it embedded and controlled in the container, but the need for holding onto a message until we ack is a requirement for this app.
>
I don't completely follow what you are trying to do, but, no, MQ isn't bundled as an osgi module.
Nigel
> Thanks!
>
>
> Robert Weeks
> Senior Software Developer
> EXTENSION, INC.
> Email: rweeks_at_ext-inc.com
> Office: 260-797-0200 x4228
> General: 877-207-3753
> www.OpenTheRedBox.com
>
> Download the FREE EXTENSION Mobile App for iPhone and iPod Touch
> http://www.opentheredbox.com/iPhone_appDemo.php
>
> Email us at demo_at_ext-inc.com<mailto:demo_at_ext-inc.com> to pre-schedule a LIVE demo for our HealthAlert for Nurses solution at the AONE Conference in San Diego. Visit us at booth #118
>
>
>
> ________________________________________
> From: Nigel Deakin [nigel.deakin_at_oracle.com]
> Sent: Wednesday, March 23, 2011 8:13 AM
> To: users_at_glassfish.java.net
> Subject: Re: Setting AcknowledgeMode on a Session (Direct)
>
> Good question. The reason for this behaviour is that the arguments to createSession() are handled differently in a Java
> EE environment than in a simple JMS client.
>
> Please look at the EJB 3.1 Spec, section 13.3.5 "Use of JMS APIs in Transactions" (which also applies to web applications):
>
> This states: "Because the container manages the transactional enlistment of JMS sessions on behalf of a bean, the
> parameters of the createSession(boolean transacted, int acknowledgeMode), createQueueSession(boolean transacted, int
> acknowledgeMode) and createTopicSession(boolean transacted, int acknowledgeMode) methods are ignored. It is recommended
> that the Bean Provider specify that a session is transacted, but provide 0 for the value of the acknowledgment mode."
>
> It continues: "The Bean Provider should not use the JMS acknowledge method either within a transaction or within an
> unspecified transaction context. Message acknowledgment in an unspecified transaction context is handled by the container."
>
> So client acknowledgement is not allowed. Because of this the argument Session.CLIENT_ACKNOWLEDGE is ignored. If there's
> no transaction then the message will be automatically acknowleged (AUTO_ACKNOWLEDGE), or if there a transaction then the
> message will be acknowledged when the transaction is committed.
>
> Nigel
>
>
> On 22/03/2011 20:10, Robert Weeks wrote:
>> Hello -
>>
>> Using GF3.1, when trying to set an AcknowledgeMode on a session, it never seems to stick.
>>
>> I am pulling a ConnectionFactory from jndi for us:
>>
>> create-jms-resource --restype javax.jms.QueueConnectionFactory --description "QueueConnectionFactory" jms/ExtQueueConnectionFactory
>>
>> When I get this back - it reports as: com.sun.messaging.jms.ra.DirectConnectionFactory
>>
>> Then - trying to create a session with CLIENT_ACKNOWLEDGE and then immediately testing it:
>>
>>
>> Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
>> This results in the object:
>> >> SESSION: com.sun.messaging.jms.ra.DirectTransactionManagedSession_at_967e07
>>
>>
>> Checking transacted (log.error(">> Are we transacted? " + session.getTransacted())) we get:
>> >> Are we transacted? false
>>
>> Then immediately trying to get what the acknowledgeMode is on the session we just created:
>> session.getAcknowledgeMode(): 1 (AUTO_ACKNOWLEDGE)
>>
>> If I write an app and connect to the message queue non-direct (via mq://127.0.0.1:7676), this works fine - but that is not returning the DirectConnectionFactory nor the DirectConnection - and the session is slightly different too.
>>
>> It appears that the session is not transacted (which is right) - but I cannot get the setting of the ack mode to be correct here.
>>
>> Is there something I am missing?
>>
>> Thanks for any information.
>>