Author |
Message
|
belal |
Posted: Tue Jan 02, 2007 1:43 am Post subject: websphere and with mq series transaction |
|
|
Novice
Joined: 14 Dec 2006 Posts: 15
|
Hi
I am using websphere and with mq series
I have a session bean configured as container transaction bean.
I am sending a message to mq series queue and i need to do that in the global transaction of the app server so that if an exception is thrown, this message must roll back.
The problem is not to write the transaction in this code. I need to rely on the app server transaction management and to specify somewhere that my code (here after) will be in the same transaction that other codes managed by the app server within the same transaction.
How can I perform that ?
I am using the following code to send the message. With this code the rollback doesn't happen and the message remains in the queue.
MQQueueManager qMgr = new MQQueueManager("QM1");
int openOption = MQC.MQOO_OUTPUT | MQC.MQOO_SET_IDENTITY_CONTEXT;
MQQueue put_queue = qMgr.accessQueue("myQueue", openOption);
MQMessage putmsg= new MQMessage();
putmsg.format = "..."
putmsg.applicationIdData = "....."
putmsg.writeString("my message");
MQPutMessageOption pmo = new MQPutMessageOption();
pmo.options = MQC.MQPMO_SET_IDENTITY_CONTEXT;
put_queue.put(putmsg, pmo);
put_queue.close();
Thanx for your help. Any information would be of a great help. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Jan 02, 2007 2:03 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
The Application Programming manuals contain information on the "syncpoint" option missing from your code.
Those and similar manuals provide details on using MQ with an external transaction coordinator (in this case the app server).
Happy Reading!  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jan 02, 2007 2:32 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I guess you should be using JMS instead of the plain MQ API. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
belal |
Posted: Tue Jan 02, 2007 2:35 am Post subject: |
|
|
Novice
Joined: 14 Dec 2006 Posts: 15
|
no i don't want to use jms I need to use mq API |
|
Back to top |
|
 |
belal |
Posted: Tue Jan 02, 2007 2:37 am Post subject: |
|
|
Novice
Joined: 14 Dec 2006 Posts: 15
|
do I have to do something in the application server cofiguration or just in the code |
|
Back to top |
|
 |
Vitor |
Posted: Tue Jan 02, 2007 2:42 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
belal wrote: |
do I have to do something in the application server cofiguration or just in the code |
As I said in my previous post:
a) you need to change the code to ensure the MQ calls are in a unit of work
b) you need to configure MQ to use an external transaction coordinator
This is all documented.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jan 02, 2007 2:57 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You want to use container managed transactions.
This is a set of requirements that you should be using JMS to meet.
If you only want to perform a transaction with MQ, then you can just use the syncpoint options that Vitor mentions with the base MQ - but this is NOT using a container managed transaction, you're managing the transaction on your own in your own code.
If you want to perform a transaction between both MQ and something else, like JDBC, then it gets more complicated - and again, you SHOULD be using JMS.
I repeat, as far as I know, the only way to have your CONTAINER manage your transactions, is to use the JEE standard, which is JMS. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
belal |
Posted: Tue Jan 02, 2007 6:10 am Post subject: |
|
|
Novice
Joined: 14 Dec 2006 Posts: 15
|
thanx Vitor
but how can i congigure my application server (websphere) as external transaction coordinator
thank you very much |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jan 02, 2007 6:29 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You have incompatible requirements.
You have said
1) You want the container to manage your transactions without changing your code
2) You don't want to use JMS.
You can't do both of those. You can do one or the other.
Are you involving ANYTHING else, like a database in the same transaction? If not, then nothing that Vitor says has any bearing. He's talking about configuring your queue manager so that it can participate in XA/globally coordinated transactions. That's generally a complicated subject. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
belal |
Posted: Tue Jan 02, 2007 6:35 am Post subject: |
|
|
Novice
Joined: 14 Dec 2006 Posts: 15
|
I don't want to use JMS
but i can change my code if that mean "the container manage the transactions "
there is no data base |
|
Back to top |
|
 |
Vitor |
Posted: Tue Jan 02, 2007 6:40 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
If there's no external system, stick with the syncpoint options. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jan 02, 2007 7:34 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Vitor wrote: |
If there's no external system, stick with the syncpoint options. |
But that will be his code managing the transaction, and not the container (app server). _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Jan 02, 2007 7:43 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
You've already said - to use container manager transactions requires JMS. He's said he doesn't want to do that.
For the record, I agree with you that's the best way but not the way belal has indicated he wants to go. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
belal |
Posted: Tue Jan 02, 2007 7:52 am Post subject: |
|
|
Novice
Joined: 14 Dec 2006 Posts: 15
|
I don't know what i have to do
syncpoint is not suitable cause cause the container will not manage the transaction
and I want to send mq message with the option of ccsid ,...... so i can't use jms
how can I make websphere application server the external transaction coordinator
thanx for all of you  |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jan 02, 2007 8:00 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You should not need to specify a particular, non-default CCSID when sending a message.
You should be able to specify a CCSID on a JMS message by setting the string property "JMS_IBM_Character_Set". This is a JMS provider specific property, so it will not be portable between different providers.
But again, you should not need to do this. Why do you think you need to do this? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|