Package org.mule.api.transaction

Examples of org.mule.api.transaction.TransactionConfig


        // don't wait for ages, has to be set before TX is begun
        tm.setTransactionTimeout(TRANSACTION_TIMEOUT_SECONDS);

        // this is one service with a TX always begin
        TransactionConfig config = new MuleTransactionConfig();
        config.setFactory(new XaTransactionFactory());
        config.setAction(TransactionConfig.ACTION_ALWAYS_BEGIN);
        TransactionTemplate template = new TransactionTemplate(config, muleContext);

        // and the callee service which should join the current XA transaction, not begin a nested one
        final TransactionConfig nestedConfig = new MuleTransactionConfig();
        nestedConfig.setFactory(new XaTransactionFactory());
        nestedConfig.setAction(TransactionConfig.ACTION_BEGIN_OR_JOIN);

        // start the call chain
        template.execute(new TransactionCallback<Void>()
        {
            public Void doInTransaction() throws Exception
View Full Code Here


        return (InboundEndpoint) getTestEndpoint(null, null, null, null, null, context, new EndpointSource()
        {
            public ImmutableEndpoint getEndpoint(EndpointBuilder builder) throws MuleException
            {
                builder.setExchangePattern(mep);
                TransactionConfig txConfig = new MuleTransactionConfig();
                txConfig.setAction(TransactionConfig.ACTION_BEGIN_OR_JOIN);
                txConfig.setFactory(new TestTransactionFactory());
                builder.setTransactionConfig(txConfig);
                return context.getEndpointFactory().getInboundEndpoint(builder);
            }
        }, null);
    }
View Full Code Here

    final Integer maxRes = parseMaxResults(maxResults);
    final Integer startPos = parseStartPosition(startPosition);

    if (startTransaction) {
      TransactionConfig config = new MuleTransactionConfig();
      config.setFactory(new XaTransactionFactory());
      config.setAction(TransactionConfig.ACTION_ALWAYS_BEGIN);
      ExecutionTemplate<Object> executionTemplate = TransactionalExecutionTemplate.createTransactionalExecutionTemplate(muleContext, config);
      try {
        return executionTemplate.execute(new ExecutionCallback<Object>() {
          public Object process() throws Exception {
            return callback.process(executeJpaQuery(query, Boolean.FALSE, null, maxRes, startPos));
View Full Code Here

        String inboundProtocol = inboundEndpoint.getConnector().getProtocol();
        String outboundProtocol = outboundEndpoint.getConnector().getProtocol();

        boolean needXA = !inboundProtocol.equals(outboundProtocol);

        TransactionConfig inboundTransactionConfig = inboundEndpoint.getTransactionConfig();

        if (inboundTransactionConfig.getFactory() == null)
        {
            TransactionFactory transactionFactory = needXA
                                                          ? new XaTransactionFactory()
                                                          : getTransactionFactory(inboundProtocol);

            inboundTransactionConfig.setFactory(transactionFactory);
        }

        TransactionConfig outboundTransactionConfig = outboundEndpoint.getTransactionConfig();

        if (outboundTransactionConfig.getFactory() == null)
        {
            TransactionFactory transactionFactory = needXA
                                                          ? new XaTransactionFactory()
                                                          : getTransactionFactory(outboundProtocol);
            outboundTransactionConfig.setFactory(transactionFactory);
        }
    }
View Full Code Here

        InboundEndpoint ep = mock(InboundEndpoint.class);
        when(ep.getAddress()).thenReturn("http://localhost:8080/foo");
        when(ep.getName()).thenReturn("test");
        when(ep.getEndpointURI()).thenReturn(new MuleEndpointURI("http://localhost:8080/foo", muleContext));
        TransactionConfig txConfig = mock(TransactionConfig.class);
        when(ep.getTransactionConfig()).thenReturn(txConfig);
        when(ep.getExchangePattern()).thenReturn(MessageExchangePattern.REQUEST_RESPONSE);

        DefaultMuleEvent event = new DefaultMuleEvent(message, ep, (FlowConstruct)null);
        return event;
View Full Code Here

{
    private final ExecutionInterceptor<MuleEvent> processingInterceptor;

    private ErrorHandlingExecutionTemplate(final MuleContext muleContext, final MessagingExceptionHandler messagingExceptionHandler)
    {
        final TransactionConfig transactionConfig = new MuleTransactionConfig();
        final boolean processTransactionOnException = false;
        ExecutionInterceptor<MuleEvent> tempExecutionInterceptor = new ExecuteCallbackInterceptor<MuleEvent>();
        tempExecutionInterceptor = new HandleExceptionInterceptor(tempExecutionInterceptor, messagingExceptionHandler);
        tempExecutionInterceptor = new BeginAndResolveTransactionInterceptor<MuleEvent>(tempExecutionInterceptor,transactionConfig,muleContext, processTransactionOnException, false);
        tempExecutionInterceptor = new SuspendXaTransactionInterceptor<MuleEvent>(tempExecutionInterceptor,transactionConfig,processTransactionOnException);
View Full Code Here

        {
            @Override
            public ImmutableEndpoint getEndpoint(EndpointBuilder builder) throws MuleException
            {
                builder.setExchangePattern(mep);
                TransactionConfig txConfig = new MuleTransactionConfig(TransactionConfig.ACTION_BEGIN_OR_JOIN);
                txConfig.setFactory(new TestTransactionFactory());
                builder.setTransactionConfig(txConfig);
                return context.getEndpointFactory().getInboundEndpoint(builder);
            }
        }, null);
    }
View Full Code Here

        final Map<String, String> properties = new HashMap<String, String>();
        final String property1 = "property1";
        final String value1 = "value1";
        properties.put(property1, value1);
       
        final TransactionConfig mockTransactionConfig = mock(TransactionConfig.class);
        final boolean deleteUnacceptedMessages = true;
        final EndpointSecurityFilter mockEndpointSecurityFilter = mock(EndpointSecurityFilter.class);
        final MessageExchangePattern messageExchangePattern = MessageExchangePattern.REQUEST_RESPONSE;
        final int responseTimeout = 5;
        final String initialState = "state1";
View Full Code Here

    public void testVmTransaction() throws Exception
    {
        ImmutableEndpoint endpoint = muleContext.getEndpointFactory().getInboundEndpoint("globalWithTx");
        assertNotNull(endpoint);
       
        TransactionConfig txConfig = endpoint.getTransactionConfig();
        assertNotNull(txConfig);
        assertEquals(TransactionConfig.ACTION_ALWAYS_BEGIN, txConfig.getAction());
        assertEquals(42, txConfig.getTimeout());
    }
View Full Code Here

    public void testCustomTransaction() throws Exception
    {
        ImmutableEndpoint endpoint = muleContext.getRegistry().lookupEndpointBuilder("customTx").buildInboundEndpoint();
        assertNotNull(endpoint);
       
        TransactionConfig txConfig = endpoint.getTransactionConfig();
        assertNotNull(txConfig);
        assertEquals(TransactionConfig.ACTION_JOIN_IF_POSSIBLE, txConfig.getAction());
        TestTransactionFactory factory = (TestTransactionFactory) endpoint.getTransactionConfig().getFactory();
        assertNotNull(factory);
        assertEquals("foo", factory.getValue());
    }
View Full Code Here

TOP

Related Classes of org.mule.api.transaction.TransactionConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.