Transaction demarcation with UserTransaction
Hi
Can any one explain, How does UserTransaction used for Bean Managed Transaction works with multiple resource managers and if in this case resources should be enabled for Two phase commit protocol?
Thanks
Java EE requires JTA. It's the JTA implementation in the application server that allows the work performed by multiple resource managers
in a transaction to have ACID properties. At the application level there's nothing special you need to do. It should all just be handled by the container.
From a deployment and server configuration perspective the requirements can differ depending on the implementation so ultimately you'd need to consult your vendor's documentation. Typically the main thing to ensure is that each resource (JDBC datasource, JMS connection factory, etc.) supports the ability to participate in 2-phase commit. For JDBC drivers, this is often designated by configuring an "XA"-capable driver.
Similar Messages
-
Container-managed / bean-managed transaction demarcation
I am trying to make sure I understand container-managed and bean-managed transaction demarcation and in particular where you have one bean calling another bean. What happens where one of the beans has container-managed transaction demarcation and the other bean-managed transaction demarcation. In fact the initial question to ask is, is this allowed?
Lets use an application scenario to illustrate the issue. The application has a payment transaction. Payments can be received in one of two ways:
1. As a payment at a branch where the individual payment is processed on a client application and resulting in the processing of a single payment transaction.
2. As a batch of payments received from a bank containing, potentially, thousands of payment transactions.
The proposed implementation for this uses two session beans. The first is a Payment session bean that implements the business logic as appropriate calling entity beans to persist the change. The second is a BatchPayment session bean. This processes the batch of payment transactions received from the bank. The BatchPayment reads through the batch of payments from a bank calling the Payment session bean for each payment transaction.
Lets look at the transactional properties of both session beans. In order to support the client application the Payment session bean can implicitly enforce transactional integrity and is therefore set to container-managed transaction demarcation. However the BatchPayment session bean will want to explicitly specify transaction demarcation for performance reasons. The transactional "commit" process is relatively expensive. When processing a large batch of transactions rather than performing a commit after every transaction is processed we want to perform the commit after a number of transactions have been processed. For example, we may decide that after every 100 transactions have been processed we commit. The processing will have a shorter elapsed time as we have not had to perform 99 commit processes. So the BatchPayment session bean will want to explicitly specify its transaction demarcation and will therefore be defined with bean-managed transaction demarcation.
How would this be implemented? A possible solution is:
Payment session bean implemented with container-managed transaction demarcation with transaction scope set to Required.
BatchPayment session bean implemented with bean-managed transaction demarcation with transaction scope set to Required.
When the client application is run it calls the Payment bean and the container-managed transaction demarcation ensures the transactional integrity of that transaction.
When a BatchPayment process is run it explicitly determines the transaction demarcation. Lets say that after every 100 Payment transactions (through 100 calls to the Payment session bean) have been processed the BatchPayment bean issues a commit. In this scenario however we have mixed container-managed and bean-managed transaction demarcation. Hence my original question. Can container-managed and bean-managed transaction demarcation be mixed? If not how is it possible to implement the requirements as described above?
Thanks for any thoughts.
PaulBatchPayment session bean implemented with bean-managed transaction demarcation with transaction scope set to Required.Didn't quite understand this sentence.... if it's BMT it has no declarative transaction attributes such as "Required"....
Anyway, first of all I'll have to ask, Why at all would you want to commit in the middle of the business method? to get as much through as possible before a potential crash? :-)
Can container-managed and bean-managed transaction demarcation be mixed?Yes, of course. Just remember that the "direction" you are refering to ->
a BMT SB that propagates it's transaction to a method in a CMT SB that is demarcated with "Required" is the simplest case. If it were "reversed", or for that matter any BMT that might be called within an active transaction context must perform logic to manipulate the transaction state. For instance(and most common case), checking to see if a transaction is active and if so not to do anything(just use the one that is already active).
If not how is it possible to implement the requirements as described above?You could also implement this scenario with CMTs all the way through. your BatchPayment SB could consist of two methods, one (say, execute(Collection paymentsToExecute) ) with "Supports", and another(say executeBatchUnit(Collection paymentsToExecute, int beginIndex, int endIndex) ) with "RequiresNew".
then have the first just call the other with indexes denoting each time a group of payments.
Still, it does seem more suitable using BMT for these kind of things.....
Hope this helped.... -
Entity Bean can only use container-managed transaction demarcation?
In <<Designing Enterprise Application with J2EE 2nd>>
Section 2.3.3.3 Enterprise Bean Transactions,it says:Entity beans can only use container-managed transaction demarcation.
That means,i can not get UserTransaction from EJBContext.
Is that true?Yes this is the requirement of the specs. Your ejb code generator should give you the error if you use usertransaction.
--Ashwani -
MDB container managed transaction demarcation not working in wls 6.1 beta
I have an MDB which sends the messages it receives onto another JMS
destination within the onMessage method. These messages are not sent to
the JMS destination unless I explicitly use a transacted session for the
destination and subsequently commit the session. If I set the transacted
parameter to Session as false the messages are sent. If I set the
transacted parameter to true the messages will only be output if the
session is committed. This is the standard behaviour for a JMS session
but this is not the correct behaviour for an MDB running with
container-managed transaction demarcation.
For a start the transacted parameter to session should be ignored when
run in the context of a container transaction and the commit method
should thrown an exception as it is not allowed within the context of a
container transaction.
This is the MDB code and the deployment descriptor: -
public class MessageBean implements MessageDrivenBean, MessageListener
private String topicName = null;
private TopicConnectionFactory topicConnectionFactory = null;
private TopicConnection topicConnection = null;
private TopicSession topicSession = null;
private Topic topic = null;
private TopicPublisher topicPublisher = null;
private TextMessage textMessage=null;
private transient MessageDrivenContext messageDrivenContext = null;
private Context jndiContext;
public final static String
JMS_FACTORY="weblogic.examples.jms.TopicConnectionFactory";
public final static String
TOPIC="weblogic.examples.jms.exampleTopic";
public MessageBean()
public void setMessageDrivenContext(MessageDrivenContext
messageDrivenContext)
this.messageDrivenContext = messageDrivenContext;
public void ejbCreate()
public void onMessage(Message inMessage)
try
jndiContext = new InitialContext();
topicConnectionFactory =
(TopicConnectionFactory)jndiContext.lookup(JMS_FACTORY);
topic = (Topic) jndiContext.lookup(TOPIC);
topicConnection =
topicConnectionFactory.createTopicConnection();
topicConnection.start();
// The transacted parameter should be ignored in the context of a
container tx
topicSession = topicConnection.createTopicSession(true,
Session.AUTO_ACKNOWLEDGE);
topicPublisher = topicSession.createPublisher(topic);
textMessage = (TextMessage)inMessage;
topicPublisher.publish(inMessage);
// this is illegal in a container transaction
topicSession.commit();
topicConnection.close();
catch (JMSException je)
throw new EJBException(je);
catch (NamingException ne)
throw new EJBException(ne);
public void ejbRemove()
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<ejb-jar>
<enterprise-beans>
<message-driven>
<display-name>MessageBean</display-name>
<ejb-name>MessageBean</ejb-name>
<ejb-class>MessageBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
<security-identity>
<description></description>
<run-as>
<description></description>
<role-name></role-name>
</run-as>
</security-identity>
</message-driven>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>MessageBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
Please see the response in the EJB newsgroup.
Also, could you kindly only post to a single newsgroup?
Thanks.
"Jimmy Johns" <[email protected]> wrote in message
news:[email protected]...
> I have an MDB which sends the messages it receives onto another JMS
> destination within the onMessage method. These messages are not sent to
> the JMS destination unless I explicitly use a transacted session for the
>
> destination and subsequently commit the session. If I set the transacted
>
> parameter to Session as false the messages are sent. If I set the
> transacted parameter to true the messages will only be output if the
> session is committed. This is the standard behaviour for a JMS session
> but this is not the correct behaviour for an MDB running with
> container-managed transaction demarcation.
>
> For a start the transacted parameter to session should be ignored when
> run in the context of a container transaction and the commit method
> should thrown an exception as it is not allowed within the context of a
> container transaction.
>
> This is the MDB code and the deployment descriptor: -
>
> public class MessageBean implements MessageDrivenBean, MessageListener
> {
> private String topicName = null;
> private TopicConnectionFactory topicConnectionFactory = null;
> private TopicConnection topicConnection = null;
> private TopicSession topicSession = null;
> private Topic topic = null;
> private TopicPublisher topicPublisher = null;
> private TextMessage textMessage=null;
> private transient MessageDrivenContext messageDrivenContext = null;
>
> private Context jndiContext;
>
> public final static String
> JMS_FACTORY="weblogic.examples.jms.TopicConnectionFactory";
> public final static String
> TOPIC="weblogic.examples.jms.exampleTopic";
>
> public MessageBean()
> {
> }
>
> public void setMessageDrivenContext(MessageDrivenContext
> messageDrivenContext)
> {
> this.messageDrivenContext = messageDrivenContext;
> }
>
> public void ejbCreate()
> {
> }
>
> public void onMessage(Message inMessage)
> {
> try
> {
> jndiContext = new InitialContext();
> topicConnectionFactory =
> (TopicConnectionFactory)jndiContext.lookup(JMS_FACTORY);
> topic = (Topic) jndiContext.lookup(TOPIC);
> topicConnection =
> topicConnectionFactory.createTopicConnection();
> topicConnection.start();
> // The transacted parameter should be ignored in the context of a
> container tx
> topicSession = topicConnection.createTopicSession(true,
> Session.AUTO_ACKNOWLEDGE);
> topicPublisher = topicSession.createPublisher(topic);
> textMessage = (TextMessage)inMessage;
> topicPublisher.publish(inMessage);
> // this is illegal in a container transaction
> topicSession.commit();
> topicConnection.close();
> }
> catch (JMSException je)
> {
> throw new EJBException(je);
> }
> catch (NamingException ne)
> {
> throw new EJBException(ne);
> }
> }
>
> public void ejbRemove()
> {
> }
> }
>
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise
> JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
>
> <ejb-jar>
> <enterprise-beans>
> <message-driven>
> <display-name>MessageBean</display-name>
> <ejb-name>MessageBean</ejb-name>
> <ejb-class>MessageBean</ejb-class>
> <transaction-type>Container</transaction-type>
> <message-driven-destination>
> <destination-type>javax.jms.Queue</destination-type>
> </message-driven-destination>
> <security-identity>
> <description></description>
> <run-as>
> <description></description>
> <role-name></role-name>
> </run-as>
> </security-identity>
> </message-driven>
> </enterprise-beans>
> <assembly-descriptor>
> <container-transaction>
> <method>
> <ejb-name>MessageBean</ejb-name>
> <method-name>*</method-name>
> </method>
> <trans-attribute>Required</trans-attribute>
> </container-transaction>
> </assembly-descriptor>
> </ejb-jar>
>
>
>
>
>
>
>
>
-
Sale order transaction held with error in MMT interface
A sale order is shipped from order management but it entry struck in transaction interface with anonymous error, error code is “Oracle error”, we are unable to diagnose that what is the cause of struck transactions. Pl guide what should we do?
Regards,I gues you need to open Oracle SR to trouble shoot the issue
Mahendra -
How to preset fields in a transaction BP with default values
Hi!
I want to fill few fields in transaction BP with default values.
This should be if there`s a new business partner to insert.
If i can do this depending on the selected role it was the best
First i thought on SPA/GPA-parameters ... but then i can`t do it in depence on the selected role.
In customizing i can tell only if a field should be displayed or not, for input or not, ... but no values to insert.
Is here anybody with a good idea for me?
I`ve posted my question first in crm-section but i think here it`s better
Thanks a lot in advance.
Best regards,
IngoHi,
There is one possibility which requires an enhancement of the
BDT event ISDAT and a call to the function module
BUP_BUPA_FIELDVALUES_SET. This means that an ISDAT function module needs to be written (transaction BUS7) which calls the function module BUP_BUPA_FIELDVALUES_SET with the needed values that are to be defaulted. You can read the role value using BUS_PARAMETERS_ISSTA_GET (T_RLTYP).The fields which are possible can be found in the DDIC structure BUSDEFAULT. However this is limited only to the fields inside this structure.
Thanks and warm regards,
Smita. -
Hello All,
I am getting below error can you please help me
Error:-
The transaction associated with the current connection has completed but has not been disposed. The transaction must be disposed before the connection can be used to execute SQL statements.Perhaps this thread will help you out
http://stackoverflow.com/questions/11453066/error-the-transaction-associated-with-the-current-connection-has-completed-but
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Pairing of EDI ASNI X.12 Transactions set with suitalbe SAP IDoc types
Hello,
I am looking to pair the following EDI ASNI X.12 Transactions set with suitalbe SAP IDoc types, for our EDI Integration.
Can some one help me to identify which suitable IDoc type, should I use? Your help is greatly appreciated.
142
824
830
846
853
861
862
864
866
I am not sure, I am seeking the help in the righr forum -:)
Thanks in advance.
NamadevHi namadev
Please you can check this link.
http://www.erpgenie.com/sap/sapedi/ansi.htm#Mapping_x12_to_SAP
thanks. -
Call a Transaction iView with parameters
Hello,
can anyone help me with the following problem:
I'll just tried to call the transaction RECN with a transaction iView. When I test the iView it works but not with any parameters in the URL.
I'll tried the parameters fix in the iView properties but without any result.
Can someone tell me the correct syntax? I'll tried everything I can find in the SAP help and here in the forum.
Have someone a how to for calling transaction iView with dynamical parameters?
Thanks for help!
Best regards
MartinMartin,
Have you had a look at these yet?
http://wiki.sdn.sap.com/wiki/display/EP/StartanSAPtransactionfromaURL
How to launch SAP transaction & pass parameters via URL
Cheers!
Sandeep Tudumu -
Starting R/3 Transaction iView with dynamic parameters
Hi,
I looked around here for a while searching an answer but couldn't find one. Excuse me if I overlooked something about this rather simple question (I guess).
I have a BW query iView which displays a list of items, lets say order numbers. I would like to click on this number and open a specific R/3 transaction iView with the given order number processed.
I succesfully implement this iView with the property "application parameters" in the form "XYZ=0012345" and it works. But of course, the order number should be dynamically set. I tried to call the iview via the "NavigationTarget=ROLES:/.../iViewID?XYZ=0012345" etc. which starts the transaction, but the parameter is not recognized.
Thanks for any useful hints.
UweHi Uwe,
perhaps the Guide:
<a href="http://service.sap.com/~form/sapnet?_SCENARIO=01100035870000000112&_SHORTKEY=00200797470000065927&_OBJECT=011000358700000384062005E&">How To Enable Portal Navigation From BW to PCUI Applications</a>
Gives you some hints.
Regards
Gregor -
SQL Server 2012 Transactional Replication with updateable subscriptioins
Hi All,
It is heard that Transactional Replication with Updateable Subscriptions
is
deprecated in SQL 2012 so it is not possible to configure through the wizards but
we can still configure it by using T-SQL Script. Would you please share that script if possible to configure the same in SQL Server 2012. Thank You.
Regards,
Kalyan
----Learners Curiosity Never Ends----Thanks for the information,
I understand that you have got the answer yourself and post it, Therefor I mark your answer. If this is still open question please inform us.
[Personal Site] [Blog] [Facebook] -
Hi,
I have written entity bean and tried to verify it in J2EE 1.4 SDK in Deploytool.
It's giving me one error about findByPromaryKey() and findBySalary() methods in SalaryHome interface and description of error is something like "...Transaction Demarcation Error...".
Any idea when it comes and how to resolve it?
Any help is appreciated.
Thanks
Rajeev.These methods should have container-transaction attributes defined for them in the ejb deployment descriptor, ejb.xml.
<container-transaction>
<method>
<ejb-name>TestBeanEJB</ejb-name>
<method-intf>Home</method-intf>
<method-name>findByPrimaryKey</method-name>
<method-params>
<method-param>java.lang.Integer</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction> -
Hideing menu in Transaction iview with GUI for HTML
hi,
I have created a transaction iview with ITS
now the requirement is that user should not see any menu
i have googled and found some abstract information like
~singletransaction.
~webgui = 1
~generatedynpro = 1
not clear with how and where to do it
please let me know if it is possible to hide the menu from IView it self by passing some parameters
Thanks,
PavanHi Pavan,
Refer to this
http://wiki.sdn.sap.com/wiki/display/HOME/Article-EmploySAPGUIforHTMLinsteadofanInternet+service
You need to modify the WEBGUI service for this.
In transaction SICF, Navigate to dafault_host->sap->bc->gui->sap->its->webgui.
Thanks
Prashant -
New transaction key with the posting key 24 and 34
Hi,
i want to create a new transaction key with the posting key 24 and 34.
the corresponding table is T030B.
but what is the Tcode/ IMG path to create it?
Regards,
SwethaHi,
Go to FBKP. Click on Automatic Postings.
Suppose you want to see the Exchange Rate diff. then click on it. You will see the transaction. Suppose KDB. Then double click on it. Now click on posting keys. The same will be defined in the table which is given by you.
Regards,
Jigar -
Bapi to simulate transaction mb1b with WBS ELEMENT
Hello people, I need a Bapi which simulates transaction 'MB1B' with Reservation and using a wbs element.
Any idea?¿
Thks.Look at BAPI_RESERVATION_CREATE1
rgd
Frédéric
(next time search the BAPI with transaction BAPI or in ifr.sap.com)
Maybe you are looking for
-
Set curser in a VI which frontpanel is not opend
Hi, I've the following problem: A Sub-VI which has several initialisation routines while start-up (takes about ~10sec). I want to set the cursor to 'busy' for this time. The sub VI sets the cursor to 'busy' while start up, and after finishing the ini
-
Dynamic configuration of Adpater in SAP PI
Hi, I have a requirement where in I have to dynamically configure connection adpater in SAP PI 7.1 EHP 1, the configuration data will be pulled form database on the bases of the message content. Thanks in advance. Gautam
-
Invalid cursor state error while executing the prepared statement
hai friends, following code showing the invalid cursor state error while executing the second prepared statement. pls anyone help me String query = "select * from order_particulars where order_no=" + orderno + " order by sno"; psmt1 = con
-
Table not displaying correctly
Hi there, I have set up a table on a page in my site for links to a photo gallery. However, when I go to preview it in the browser, the space between all the cells spreads out more than I want it to. Below I have attached the code for the table. Am
-
I have a desktop Mac that I bought a couple years ago that has never had any problems until now. Yesterday, I placed a blank CD into the computer and after I was finished burning some music onto it, I attempted to eject it. It made the normal "eject