Page 1 of 1
Re: About Question enthuware.oce-ejbd.v6.2.415 :
Posted: Sun May 13, 2012 7:51 am
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
Re: About Question enthuware.oce-ejbd.v6.2.415 :
Posted: Sun May 13, 2012 5:25 pm
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.
Re: About Question enthuware.oce-ejbd.v6.2.415 :
Posted: Sun May 13, 2012 9:51 pm
by prakashyaji
Oops!! somehow I got confused there

Thanks a lot!!
Re: About Question enthuware.oce-ejbd.v6.2.415 :
Posted: Sun Dec 02, 2012 4:06 pm
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.
"
Re: About Question enthuware.oce-ejbd.v6.2.415 :
Posted: Sun Dec 02, 2012 6:22 pm
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.
Re: About Question enthuware.oce-ejbd.v6.2.415 :
Posted: Sun Feb 01, 2015 8:28 am
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

Re: About Question enthuware.oce-ejbd.v6.2.415 :
Posted: Sun Feb 01, 2015 8:35 am
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
Re: About Question enthuware.oce-ejbd.v6.2.415 :
Posted: Thu Apr 30, 2015 6:24 pm
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.
Re: About Question enthuware.oce-ejbd.v6.2.415 :
Posted: Thu Apr 30, 2015 10:34 pm
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.
Re: About Question enthuware.oce-ejbd.v6.2.415 :
Posted: Wed Nov 25, 2015 7:59 am
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.
Re: About Question enthuware.oce-ejbd.v6.2.415 :
Posted: Wed Nov 25, 2015 7:04 pm
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.