Java Code Examples for com.gs.fw.common.mithra.MithraManager#setTransactionTimeout()

The following examples show how to use com.gs.fw.common.mithra.MithraManager#setTransactionTimeout() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HelloReladomoApp.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private void initialiseReladomo() throws Exception
{
    try
    {
        logger.info("Transaction Timeout is " + MAX_TRANSACTION_TIMEOUT);
        MithraManager mithraManager = MithraManagerProvider.getMithraManager();
        mithraManager.setTransactionTimeout(MAX_TRANSACTION_TIMEOUT);
        // Notification should be configured here. Refer to notification/Notification.html under reladomo-javadoc.jar.
    }
    catch (Exception e)
    {
        logger.error("Unable to initialise Reladomo!", e);
        throw new Exception("Unable to initialise Reladomo!", e);
    }
    logger.info("Reladomo has been initialised!");
}
 
Example 2
Source File: OutgoingAsyncTopicTest.java    From reladomo with Apache License 2.0 6 votes vote down vote up
protected void setupMithra()
{
    final MithraManager mithraManager = MithraManagerProvider.getMithraManager();
    final String mithraRuntimeConfig = "ReladomoJmsTestConfig.xml";
    System.setProperty("h2.additionalArguments", ";MVCC=TRUE");
    mithraTestResource = new MithraTestResource(mithraRuntimeConfig);
    ConnectionManagerForTests connectionManagerForTestTradeDb = ConnectionManagerForTests.getInstance("test_trade_db");
    mithraTestResource.createSingleDatabase(connectionManagerForTestTradeDb);

    this.mithraTestResource.setUp();

    multiThreadedTm = new MultiThreadedTm();
    mithraManager.setJtaTransactionManagerProvider(new JtaProvider()
    {
        @Override
        public TransactionManager getJtaTransactionManager()
        {
            return multiThreadedTm;
        }
    });
    mithraManager.setTransactionTimeout(180); // short timeout for testing topic processor
}
 
Example 3
Source File: MithraTestApp.java    From reladomo with Apache License 2.0 5 votes vote down vote up
private void initialiseMithra() throws Exception
{
    try
    {
        logger.info("Transaction Timeout is " + this.getMaxTransactionTimeout());
        MithraManager mithraManager = MithraManagerProvider.getMithraManager();
        mithraManager.setTransactionTimeout(this.getMaxTransactionTimeout());
    }
    catch (Exception e)
    {
        logger.error("Unable to initialise Mithra!", e);
        throw new Exception("Unable to initialise Mithra!", e);
    }
    logger.info("Mithra has been initialised!");
}
 
Example 4
Source File: SimpleBankServer.java    From reladomo-kata with Apache License 2.0 5 votes vote down vote up
protected void initReladomo(String runtimeConfigXML) throws Exception
{
    MithraManager mithraManager = MithraManagerProvider.getMithraManager();
    mithraManager.setTransactionTimeout(60 * 1000);
    InputStream stream = loadReladomoXMLFromClasspath(runtimeConfigXML);
    MithraManagerProvider.getMithraManager().readConfiguration(stream);
    stream.close();
}
 
Example 5
Source File: SimpleBankApp.java    From reladomo-kata with Apache License 2.0 5 votes vote down vote up
private void initReladomo() throws Exception
{
    MithraManager mithraManager = MithraManagerProvider.getMithraManager();
    mithraManager.setTransactionTimeout(60 * 1000);
    InputStream stream = loadReladomoXMLFromClasspath("SimpleBankRuntimeConfiguration.xml");
    MithraManagerProvider.getMithraManager().readConfiguration(stream);
    stream.close();
}
 
Example 6
Source File: ReladomoApplication.java    From tutorials with MIT License 5 votes vote down vote up
public static void main(String[] args) {

        try {
            ReladomoConnectionManager.getInstance().createTables();
        } catch (Exception e1) {
            e1.printStackTrace();
        }

        MithraManager mithraManager = MithraManagerProvider.getMithraManager();
        mithraManager.setTransactionTimeout(120);

        try (InputStream is = ReladomoApplication.class.getClassLoader().getResourceAsStream("ReladomoRuntimeConfig.xml")) {
            MithraManagerProvider.getMithraManager().readConfiguration(is);

            Department department = new Department(1, "IT");
            Employee employee = new Employee(1, "John");
            department.getEmployees().add(employee);
            department.cascadeInsert();

            Department depFound = DepartmentFinder.findByPrimaryKey(1);
            System.out.println("Department Name:" + department.getName());

            Employee empFound = EmployeeFinder.findOne(EmployeeFinder.name().eq("John"));
            System.out.println("Employee Id:" + empFound.getId());
            empFound.setName("Steven");
            empFound.delete();
            Department depDetached = DepartmentFinder.findByPrimaryKey(1).getDetachedCopy();

            mithraManager.executeTransactionalCommand(tx -> {
                Department dep = new Department(2, "HR");
                Employee emp = new Employee(2, "Jim");
                dep.getEmployees().add(emp);
                dep.cascadeInsert();
                return null;
            });
            
        } catch (java.io.IOException e) {
            e.printStackTrace();
        }
    }
 
Example 7
Source File: MithraTestResource.java    From reladomo with Apache License 2.0 4 votes vote down vote up
private void initializeMithraManager(MithraConfigurationManager manager)
{
    MithraManager mithra = MithraManagerProvider.getMithraManager();
    mithra.setTransactionTimeout(60); // reset to default
    this.initializeMithraManagerConfigManager(mithra, manager);
}
 
Example 8
Source File: BitemporalBankServer.java    From reladomo-kata with Apache License 2.0 4 votes vote down vote up
protected void initReladomo(String runtimeConfigXML) throws Exception
{
    MithraManager mithraManager = MithraManagerProvider.getMithraManager();
    mithraManager.setTransactionTimeout(60 * 1000);
    loadReladomoXML(runtimeConfigXML);
}
 
Example 9
Source File: BitemporalBankApp.java    From reladomo-kata with Apache License 2.0 4 votes vote down vote up
private void initReladomo() throws Exception
{
    MithraManager mithraManager = MithraManagerProvider.getMithraManager();
    mithraManager.setTransactionTimeout(60 * 1000);
    loadReladomoXML("BitemporalBankRuntimeConfiguration.xml");
}