About Question enthuware.oce-ejbd.v6.2.415 :

Moderator: admin

Post Reply
prakashyaji
Posts: 25
Joined: Sun May 13, 2012 1:39 am
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.415 :

Post by prakashyaji »

Hi Paul,
I think there's a mistake...
For option 3: You specify the acknowledgement mode while creating a connection.
explanation: "acknowledgement mode is the second parameter to connection.createSession(...)"

createSession takes 2 arguments. Doc says as follows.

public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException
Creates a Session object.

Parameters:
transacted - indicates whether the session is transacted
acknowledgeMode - indicates whether the consumer or the client will acknowledge any messages it receives; ignored if the session is transacted. Legal values are Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, and Session.DUPS_OK_ACKNOWLEDGE.
Returns:
a newly created session
Throws:
JMSException - if the Connection object fails to create a session due to some internal error or lack of support for the specific transaction and acknowledgement mode

So, if the first parameter is false, second parameter is considered. It's not given if first parameter is true or false in the question. So, Option 1 and 3 both should be correct.... Please confirm.

Regards,
Prakash Yaji

Online
admin
Site Admin
Posts: 10045
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.415 :

Post by admin »

Option 3 is wrong because it says you can specify the acknowledgement mode while creating a connection. connection is wrong. It should be session to make it correct.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

prakashyaji
Posts: 25
Joined: Sun May 13, 2012 1:39 am
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.415 :

Post by prakashyaji »

Oops!! somehow I got confused there :P Thanks a lot!!

zfvit

Re: About Question enthuware.oce-ejbd.v6.2.415 :

Post by zfvit »

Since createSession are ignored in EJB 3.1, I think that the "right" answer (When you create a session, you specify whether it is transacted.) is wrong.

From the spec:

"
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.
"

Online
admin
Site Admin
Posts: 10045
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.415 :

Post by admin »

zfvit, What you've quoted ( Section 13.3.5 ) is applicable only for CMT beans. Since the container manages transactions for a CMT bean the parameters don't make sense. But they do make sense for BMT beans. So in a situation where you are in fact able to control the transactions, you need to use the session and not the connection. That is why this option is marked correct.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

renatumb
Posts: 47
Joined: Mon Apr 08, 2013 7:55 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.415 :

Post by renatumb »

The 1st question says:
When you create a session, you specify whether it is transacted.
But on this code, I didnt have to specify nothing at creation of session

Code: Select all

            javax.jms.Connection        conn    = connectionFactory.createConnection();
            javax.jms.Session           ses     = conn.createSession();
            javax.jms.MessageProducer   prod    = ses.createProducer(myQueue);
            javax.jms.Message           mes     = ses.createTextMessage("messages content!");
Also, I couldnt find the mehod createSession() on java's 6 ee API
http://docs.oracle.com/javaee/6/api/ind ... mmary.html

I am confused :(

renatumb
Posts: 47
Joined: Mon Apr 08, 2013 7:55 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.415 :

Post by renatumb »

renatumb wrote:The 1st question says:
When you create a session, you specify whether it is transacted.
But on this code, I didnt have to specify nothing at creation of session

Code: Select all

            javax.jms.Connection        conn    = connectionFactory.createConnection();
            javax.jms.Session           ses     = conn.createSession();
            javax.jms.MessageProducer   prod    = ses.createProducer(myQueue);
            javax.jms.Message           mes     = ses.createTextMessage("messages content!");
Also, I couldnt find the mehod createSession() on java's 6 ee API
http://docs.oracle.com/javaee/6/api/ind ... mmary.html

I am confused :(

Sorry, my mitake:
Even though I have configured NetBeans to work with java 6 EE, somehow it is using java 7 ee's code

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.415 :

Post by himaiMinh »

Section 13.3.5 is applicable only for CMT beans. Since the container manages transactions for a CMT bean the parameters don't make sense. But they do make sense for BMT beans. So in a situation where you are in fact able to control the transactions, you need to use the session and not the connection. That is why this option is marked correct.
So, the question should mention that the client , which is a bean, is sending the message in BMT.

Online
admin
Site Admin
Posts: 10045
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.415 :

Post by admin »

It is a really a question about the API. The createQueueSession method takes in two arguments. The first one is transacted. This is irrespective of whether the bean is BMT or CMT. The API is same for both. That it has no meaning for a CMT is a different matter.
If you like our products and services, please help us by posting your review here.

khaled
Posts: 3
Joined: Thu Jun 18, 2015 3:42 am
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.415 :

Post by khaled »

I need to know why the second argument is relevant only to nontransacted sessions. If the session is transacted, the second argument is ignored.

regards.

Online
admin
Site Admin
Posts: 10045
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.415 :

Post by admin »

I am not sure I understand your question. If the session is transacted, there is no need for acknowledgement mode because the transaction success or failure will determine the status of the message. If the session is not transacted, then the subsystem needs to know what measures is it allowed to take to deliver the message. That is why the second parameter becomes important.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests