|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
help with jdbc transactionhow to use jdbc with transaction but without a aplication server ??
i use jotm like transaction manager transaction-manager factory="org.mule.extras.jotm.JotmTransactionManagerFactory"></transaction-manager> my application context is correct? <beans> <bean id="muleJdbcDatasource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="shutdown"> <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" /> <property name="url" value="jdbc:jtds:sqlserver://localhost/EsbusMule" /> <property name="username" value="sa" /> <property name="password" value="123" /> </bean> </beans> my mule descriptor is correct? im use org.mule.transaction.XaTransactionFactory is that ok <mule-descriptor name="TestJdbcUMO" implementation="org.mule.components.simple.BridgeComponent"> <inbound-router> <endpoint address="stream://System.in"> <properties> <property name="promptMessage" value="Please enter text...: " /> </properties> </endpoint> </inbound-router> <outbound-router> <router className="org.mule.routing.outbound.MulticastingRouter"> <endpoint address="jdbc://insertRecord" connector="jdbcConnector"> <transaction action="ALWAYS_JOIN" factory="org.mule.transaction.XaTransactionFactory"/> </endpoint> <endpoint address="jdbc://insertRecord2" connector="jdbcConnector"> <transaction action="ALWAYS_JOIN" factory="org.mule.transaction.XaTransactionFactory"/> </endpoint> <transaction action="ALWAYS_BEGIN" factory="org.mule.transaction.XaTransactionFactory"/> </router> </outbound-router> </mule-descriptor> </mule-configuration> my connector is: <connector name="jdbcConnector" className="org.mule.providers.jdbc.JdbcConnector"> <properties> <container-property name="dataSource" reference="muleJdbcDatasource" required="true" /> <map name="queries"> <property name="insertRecord" value="INSERT into Testing (description) VALUES (${pname},${payload})" /> <property name="insertRecord2" value="INSERT into Testing2 (datasmall) VALUES (${payload})" /> </map> </properties> </connector> my problem is that with this configuration my messages do not transaction and always execute commint, even though in insertRecord2 it happens an error Thanks for its aid |
|
|
Re: help with jdbc transactionYou have to use XADataSource for XA transactions.
Andrew On 3/6/07, mario.sala <mario.mule@...
> wrote:
|
|
|
RE: help with jdbc transactionMario/Andrew, I’ve have also had problems recently
with JDBC and XA and I think that Mario will have other problems even he uses a
XADataSource. There appears to be a bug in JdbcConnector
that means that the XADataSource never gets enlisted in the transaction. I’ve
tracked this down to the following method in JdbcConnector: public
void setDataSource(DataSource dataSource) {
this.dataSource
= dataSource; } In order to get XA working I’ve
changed this method to: public
void setDataSource(DataSource dataSource) { if
(dataSource != null && dataSource instanceof XADataSource) { if
(MuleManager.getInstance().getTransactionManager() != null) { this.dataSource
= new DataSourceWrapper((XADataSource)dataSource, MuleManager.getInstance().getTransactionManager()); } } else
{ this.dataSource
= dataSource; } } I also had to change the doReceive method
in JdbcMessageDispatcher as it ignores the transaction at the minute: protected UMOMessage
doReceive(UMOImmutableEndpoint endpoint, long timeout) throws Exception {
if (logger.isDebugEnabled())
{
logger.debug("Trying to receive a message with a timeout of " +
timeout);
}
String[] stmts = this.connector.getReadAndAckStatements(endpoint);
String readStmt = stmts[0];
String ackStmt = stmts[1];
List readParams = new ArrayList();
List ackParams = new ArrayList();
readStmt = connector.parseStatement(readStmt, readParams);
ackStmt = connector.parseStatement(ackStmt, ackParams);
Connection con = null;
long t0 = System.currentTimeMillis();
// SM Get the transaction
UMOTransaction tx = TransactionCoordination.getInstance().getTransaction();
try
{
con = this.connector.getConnection();
if (timeout < 0)
{
timeout = Long.MAX_VALUE;
}
Object result;
do
{
result = connector.createQueryRunner().query(con, readStmt,
connector.getParams(endpoint, readParams, null),
connector.createResultSetHandler());
if (result != null)
{
if (logger.isDebugEnabled())
{
logger.debug("Received: " + result);
}
break;
}
long sleep = Math.min(this.connector.getPollingFrequency(),
timeout - (System.currentTimeMillis() - t0));
if (sleep > 0)
{
if (logger.isDebugEnabled())
{
logger.debug("No results, sleeping for " + sleep);
}
Thread.sleep(sleep);
}
else
{
logger.debug("Timeout");
return null;
}
}
while (true);
if (ackStmt != null)
{
int nbRows = connector.createQueryRunner().update(con, ackStmt,
connector.getParams(endpoint, ackParams, result));
if (nbRows != 1)
{
logger.warn("Row count for ack should be 1 and not " + nbRows);
}
}
UMOMessageAdapter msgAdapter = this.connector.getMessageAdapter(result);
UMOMessage message = new MuleMessage(msgAdapter); //
SM Check if we’re in a transaction
if (tx == null)
{
JdbcUtils.commitAndClose(con);
}
return message;
}
catch (Exception e)
{ //
SM Check if we’re in a transaction
if (tx == null)
{
JdbcUtils.rollbackAndClose(con);
}
throw e;
} } Stephen From: Andrew
Perepelytsya [mailto:aperepel@...] ****** This Message Originated From The Internet Please Be
Aware Of Suspicious Attachments And Content ****** You have to use
XADataSource for XA transactions. On 3/6/07, mario.sala
<mario.mule@... > wrote:
_________________________________________________________ DISCLAIMER 1. The information contained in this E-mail, including any files transmitted with it, is confidential and may be legally privileged. This E-mail is intended only for the personal attention of the stated addressee(s). Any access to this E-mail, including any files transmitted with it, by any other person is unauthorised. If you are not an addressee, you must not disclose, copy, circulate or in any other way use or rely on the information contained in this E-mail or any files transmitted with it. Such unauthorised use may be unlawful. If you have received this E-mail in error, please inform the sender immediately and delete it and all copies from your system. You may not forward this E-mail without the permission of the sender. 2. The views expressed in this E-mail are those of the author, and do not necessarily represent the views of AMT-SYBEX. Internet communications are not secure and AMT-SYBEX cannot, therefore, accept legal responsibility for the contents of this message nor for any damage caused by viruses.
AMT-SYBEX Limited is a UK company, registration number GB03036807 at address The Spirella Building, Bridge Road, Letchworth, SG6 4ET.
AMT-SYBEX (NI) Limited is a UK company, registration number NI024104 at address Edgewater Office Park, Edgewater Rd, Belfast, BT3 9JQ.
For more information on the AMT-SYBEX Group visit http://www.amt-sybex.com _________________________________________________________ |
|
|
Re: help with jdbc transactionStephen,
I'm not sure that is the right thing you are doing. Could you please post a detailed use case where you consider it was required? Andrew |
|
|
Re: help with jdbc transactionSingle I need a trasaction to insert in two tables without using a
applications server. Wath I need for this? is my application context correct? or where I can find information for this task, in the site it is very poor the information to this. Thank.. 2007/3/7, Andrew Perepelytsya <aperepel@...>: > Stephen, > > I'm not sure that is the right thing you are doing. Could you please post a > detailed use case where you consider it was required? > > Andrew > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
|
RE: help with jdbc transactionAndrew, Due to current pressures I won’t
have a chance to put up an example config until next week, but in the mean
time: We have a UMO that takes a message of an
ActiveMQ queue, updates a database and then publishes to another ActiveMQ queue
all within a XA transaction (note that the queues are on separate brokers). Without the changes that we have made we
got a lot of XA errors and on stepping through the code noticed that the
database was updated as soon as the insert/update was executed (i.e. before the
message had been forwarded to the outbound queue). We have had no problems with another part
of the system that bridges the two remote ActiveMQ brokers in a XA transaction
i.e. we only encountered the problem when a JDBC connection was involved. We’re using Mule 1.3.2 with ActiveMQ,
Oracle 10g and the Oracle JDBC driver. Mule is running standalone and using
JOTM as the transaction manager. Stephen From: Andrew
Perepelytsya [mailto:aperepel@...] ****** This Message Originated From The Internet Please Be
Aware Of Suspicious Attachments And Content ****** Stephen, _________________________________________________________ DISCLAIMER 1. The information contained in this E-mail, including any files transmitted with it, is confidential and may be legally privileged. This E-mail is intended only for the personal attention of the stated addressee(s). Any access to this E-mail, including any files transmitted with it, by any other person is unauthorised. If you are not an addressee, you must not disclose, copy, circulate or in any other way use or rely on the information contained in this E-mail or any files transmitted with it. Such unauthorised use may be unlawful. If you have received this E-mail in error, please inform the sender immediately and delete it and all copies from your system. You may not forward this E-mail without the permission of the sender. 2. The views expressed in this E-mail are those of the author, and do not necessarily represent the views of AMT-SYBEX. Internet communications are not secure and AMT-SYBEX cannot, therefore, accept legal responsibility for the contents of this message nor for any damage caused by viruses.
AMT-SYBEX Limited is a UK company, registration number GB03036807 at address The Spirella Building, Bridge Road, Letchworth, SG6 4ET.
AMT-SYBEX (NI) Limited is a UK company, registration number NI024104 at address Edgewater Office Park, Edgewater Rd, Belfast, BT3 9JQ.
For more information on the AMT-SYBEX Group visit http://www.amt-sybex.com _________________________________________________________ |
|
|
Re: help with jdbc transactionStephen,
Could you please describe the following details? The mule-descriptors having your jdbc endpoints, where were jdbc ones configured (inbound/outbound), what transaction attributes? Andrew
On 3/7/07, Stephen Magee <Stephen_Magee@...> wrote:
|
|
|
RE: help with jdbc transactionAndrew, The XADataSource: <bean
name="fdcsJdbcDataSource"
class="oracle.jdbc.xa.client.OracleXADataSource"> <property
name="URL" value="${fdcs.database.url}"/> <property
name="user" value="${fdcs.database.usr}"/> <property
name="password" value="${fdcs.database.pwd}"/> </bean> The JDBC connector: <connector
name="jdbcFdcsConnectorXA"
className="org.mule.providers.jdbc.JdbcConnector"> <properties> <container-property
name="dataSource" reference="fdcsJdbcDataSource"
required="true"/> <map
name="queries"> <property
name="recordWorkIssued" value= "INSERT
INTO workissued (workorderno, districtcode, issueddate, workgroupcode,
sourcefilename) VALUES
(${DFM_WORKORDER}, ${DFM_DISTRICT_CODE}, to_number(to_char(sysdate, 'YYYYMMDD')),
${DFM_WORKGROUPS}, ${originalFilename})"/> </map> </properties> <connection-strategy
className="org.mule.providers.SimpleRetryConnectionStrategy"> <properties> <property
name="doThreading" value="true"/> <property
name="retryCount" value="-1"/> <property
name="frequency" value="10000"/> </properties> </connection-strategy> </connector> The endpoint: <endpoint
name="recordWorkIssued" address="jdbc://recordWorkIssued"
connector="jdbcFdcsConnectorXA"/> The UMO (the above endpoint is called
using UMOEventContext.sendEvent(UMOMessage, UMOEndpoint) depending on logic in
the implementation class): <mule-descriptor
name="DFMDispatcherUMO"
implementation="ellipseFdcsDispatcher" singleton="false"
initialState="started"> <inbound-router> <endpoint
address="dispatcherInput" connector="jmsInternalXA"
synchronous="true"> <transaction
action="ALWAYS_BEGIN"
factory="org.mule.transaction.XaTransactionFactory"/> </endpoint> </inbound-router> <outbound-router> <router
className="org.mule.routing.outbound.OutboundPassThroughRouter"> <endpoint
address="jms://queue.afaria.fdcs-workpack-xml" connector="jmsAfariaConnector" transformers="DFMMessageToPayloadBytes
BytesToString ObjectToJMSMessage" synchronous="true"/> </router> </outbound-router> <interceptor
name="DFMInterceptorStackXA"/> <exception-strategy
className="com.amtsybex.dfm.mule.ForwardingComponentExceptionStrategy"> <global-endpoint
name="dfmAuditInterceptorXA" transformers="DFMMessageToAuditXML
ObjectToJMSMessage"/> </exception-strategy> </mule-descriptor> From: Andrew
Perepelytsya [mailto:aperepel@...] ****** This Message Originated From The Internet Please Be
Aware Of Suspicious Attachments And Content ****** Stephen, On 3/7/07, Stephen
Magee <Stephen_Magee@...>
wrote: Andrew, Due to current pressures I won't have a chance to put up an
example config until next week, but in the mean time: We have a UMO that takes a message of an ActiveMQ queue,
updates a database and then publishes to another ActiveMQ queue all within a XA
transaction (note that the queues are on separate brokers). Without the changes that we have made we got a lot of XA
errors and on stepping through the code noticed that the database was updated
as soon as the insert/update was executed (i.e. before the message had been
forwarded to the outbound queue). We have had no problems with another part of the system that
bridges the two remote ActiveMQ brokers in a XA transaction i.e. we only
encountered the problem when a JDBC connection was involved. We're using Mule 1.3.2 with ActiveMQ, Oracle 10g and the Oracle
JDBC driver. Mule is running standalone and using JOTM as the transaction
manager. Stephen _________________________________________________________ DISCLAIMER 1. The information contained in this E-mail, including any files transmitted with it, is confidential and may be legally privileged. This E-mail is intended only for the personal attention of the stated addressee(s). Any access to this E-mail, including any files transmitted with it, by any other person is unauthorised. If you are not an addressee, you must not disclose, copy, circulate or in any other way use or rely on the information contained in this E-mail or any files transmitted with it. Such unauthorised use may be unlawful. If you have received this E-mail in error, please inform the sender immediately and delete it and all copies from your system. You may not forward this E-mail without the permission of the sender. 2. The views expressed in this E-mail are those of the author, and do not necessarily represent the views of AMT-SYBEX. Internet communications are not secure and AMT-SYBEX cannot, therefore, accept legal responsibility for the contents of this message nor for any damage caused by viruses.
AMT-SYBEX Limited is a UK company, registration number GB03036807 at address The Spirella Building, Bridge Road, Letchworth, SG6 4ET.
AMT-SYBEX (NI) Limited is a UK company, registration number NI024104 at address Edgewater Office Park, Edgewater Rd, Belfast, BT3 9JQ.
For more information on the AMT-SYBEX Group visit http://www.amt-sybex.com _________________________________________________________ |
|
|
Re: help with jdbc transactionStephen,
You can put a watch on http://mule.mulesource.org/jira/browse/MULE-1479 for any follow-up. Andrew |
|
|
Re: help with jdbc transactionr8583
the fix has been applied to jdbcConnector
|
|
|
RE: help with jdbc transactionStephen
It might be due to Oracle driver that permanently changes its autocommit behaviour from version to version. In some versions XA datasource performs autocommit in other doesn't (non-XA always does). Check your driver in standalone test. Note that you need either use DataSourceWrapper or anything similar to affect this property or just find an appropriate version. Kind regards, Dmitry
|
| Free embeddable forum powered by Nabble | Forum Help |