Package org.mule.util.concurrent

Examples of org.mule.util.concurrent.Latch


        // Set SystemExceptionStrategy to redeliver messages (this can only be configured programatically for now)
        ((DefaultSystemExceptionStrategy) muleContext.getExceptionListener()).setRollbackTxFilter(new WildcardFilter("*"));

        // Tell us when a MessageRedeliverdException has been handled
        messageRedelivered = new Latch();
        muleContext.registerListener(new ExceptionNotificationListener<ExceptionNotification>()
        {
            @Override
            public void onNotification(ExceptionNotification notification)
            {
View Full Code Here


    private void startMuleContext() throws MuleException, InterruptedException
    {
        final AtomicReference<Latch> contextStartedLatch = new AtomicReference<Latch>();

        contextStartedLatch.set(new Latch());
        muleContext.registerListener(new MuleContextNotificationListener<MuleContextNotification>()
        {
            @Override
            public void onNotification(MuleContextNotification notification)
            {
View Full Code Here

    }

    @Test
    public void testSendViaGET() throws Exception
    {
        Latch latch = new Latch();
        setupAssertIncomingMessage(HttpConstants.METHOD_GET, latch, PLAIN_CONTENT_TYPE_HEADER);

        String testMessage = getTestMessage(Locale.JAPAN);
        String encodedPayload = URLEncoder.encode(testMessage, "ISO-2022-JP");
        String url = String.format("http://localhost:%1d/get?%2s=%3s",
            dynamicPort.getNumber(), HttpConnector.DEFAULT_HTTP_GET_BODY_PARAM_PROPERTY, encodedPayload);

        GetMethod method = new GetMethod(url);
        method.addRequestHeader(HttpConstants.HEADER_CONTENT_TYPE, PLAIN_CONTENT_TYPE_HEADER);
        int status = new HttpClient().executeMethod(method);
        assertEquals(HttpConstants.SC_OK, status);

        assertTrue(latch.await(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS));
        String expected = testMessage + " Received";
        String response = method.getResponseBodyAsString();
        assertEquals(expected, response);

        Header responseContentType = method.getResponseHeader(HttpConstants.HEADER_CONTENT_TYPE);
View Full Code Here

    }

    private void doTestSend(String method, Object messagePayload, Map<String, Object> messageProperties,
        String expectedContentTypeHeader) throws Exception
    {
        Latch latch = new Latch();

        setupAssertIncomingMessage(method, latch, expectedContentTypeHeader);

        MuleClient client = muleContext.getClient();
        MuleMessage reply = client.send("vm://sendBy" + method, messagePayload, messageProperties);

        assertTrue(latch.await(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS));
        assertNotNull(reply);
        assertEquals("EUC-JP", reply.getEncoding());
        assertEquals(getTestMessage(Locale.JAPAN) + " Received", reply.getPayloadAsString());
    }
View Full Code Here

    }

    @Test
    public void testPollingHttpConnector() throws Exception
    {
        final Latch latch = new Latch();
        final AtomicBoolean transformPropagated = new AtomicBoolean(false);
        muleContext.registerListener(new FunctionalTestNotificationListener()
        {
            @Override
            public void onNotification(ServerNotification notification)
            {
                latch.countDown();
                if (notification.getSource().toString().endsWith("toClient-only"))
                {
                    transformPropagated.set(true);
                }
            }
        }, "polledUMO");

        MuleClient client = muleContext.getClient();
        MuleMessage result = client.request("vm://toclient", 50000);
        assertNotNull(result.getPayload());
        assertTrue("Callback called", latch.await(1000, TimeUnit.MILLISECONDS));
        assertEquals("/foo toClient-only", result.getPayloadAsString());
        // The transform should not have been propagated to the outbound endpoint
        assertFalse(transformPropagated.get());
    }
View Full Code Here

        processingStrategy.route(mockEvent);
    }

    private void executeUntilSuccessful() throws Exception
    {
        routeCountDownLatch = new Latch();
        AsynchronousUntilSuccessfulProcessingStrategy processingStrategy = createProcessingStrategy();
        processingStrategy.route(mockEvent);
    }
View Full Code Here

            // latch ref needs to be final for listener use, wrap in atomic ref
            final AtomicReference<Latch> contextStartedLatch = new AtomicReference<Latch>();
            if (isStartContext() && null != muleContext && muleContext.isStarted() == false)
            {
                contextStartedLatch.set(new Latch());
                muleContext.registerListener(new MuleContextNotificationListener<MuleContextNotification>()
                {
                    public void onNotification(MuleContextNotification notification)
                    {
                        if (notification.getAction() == MuleContextNotification.CONTEXT_STARTED)
View Full Code Here

    }

    @Test
    public void returnsNullWhenInterruptedWhileWaitingForReply() throws Exception
    {
        final Latch fakeLatch = new Latch()
        {
            @Override
            public void await() throws InterruptedException
            {
                throw new InterruptedException();
View Full Code Here

        List<ConfigurationBuilder> builders = new ArrayList<ConfigurationBuilder>();
        builders.add(new SpringXmlConfigurationBuilder(configuration));
        MuleContextBuilder contextBuilder = new DefaultMuleContextBuilder();
        MuleContext muleContext = muleContextFactory.createMuleContext(builders, contextBuilder);
        final AtomicReference<Latch> contextStartedLatch = new AtomicReference<Latch>();
        contextStartedLatch.set(new Latch());
        muleContext.registerListener(new MuleContextNotificationListener<MuleContextNotification>()
        {
            @Override
            public void onNotification(MuleContextNotification notification)
            {
View Full Code Here

    protected void doSetUp() throws Exception
    {
        super.doSetUp();
        client = muleContext.getClient();
        inputStream = new TestByteArrayInputStream(xmlText.getBytes());
        streamReaderLatch = new Latch();
    }
View Full Code Here

TOP

Related Classes of org.mule.util.concurrent.Latch

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.