Package org.apache.camel

Examples of org.apache.camel.Exchange


            }
        }
       
        while (!newTags.empty()) {
            RepositoryTag newTag = newTags.pop();
            Exchange e = getEndpoint().createExchange();
            e.getIn().setBody(newTag);
            getProcessor().process(e);
        }
        return newTags.size();
    }
View Full Code Here


            lastOpenPullRequest = openPullRequests.get(0).getNumber();
        }

        while (!newPullRequests.empty()) {
            PullRequest newPullRequest = newPullRequests.pop();
            Exchange e = getEndpoint().createExchange();
            e.getIn().setBody(newPullRequest);
           
            // Required by the producers.  Set it here for convenience.
            e.getIn().setHeader("GitHubPullRequest", newPullRequest.getNumber());
           
            getProcessor().process(e);
        }
        return newPullRequests.size();
    }
View Full Code Here

            }
        }
       
        while (!newCommits.empty()) {
            RepositoryCommit newCommit = newCommits.pop();
            Exchange e = getEndpoint().createExchange();
            e.getIn().setBody(newCommit);
            getProcessor().process(e);
        }
        return newCommits.size();
    }
View Full Code Here

    public void testJmsRequestReplyReplyToAndReplyToHeader() throws Exception {
        // send request to foo, set replyTo to bar, but actually expect reply at baz
        Thread sender = new Thread(new Responder());
        sender.start();

        Exchange reply = template.request("jms:queue:foo", new Processor() {
            public void process(Exchange exchange) throws Exception {
                exchange.getIn().setBody(REQUEST_BODY);
            }
        });
        assertEquals(EXPECTED_REPLY_BODY, reply.getOut().getBody());
    }
View Full Code Here

    private class Responder implements Runnable {

        public void run() {
            try {
                LOG.debug("Waiting for request");
                Exchange request = consumer.receive("jms:queue:foo", 5000);

                LOG.debug("Got request, sending reply");
                final String body = request.getIn().getBody(String.class);
                final String cid = request.getIn().getHeader("JMSCorrelationID", String.class);
                final Destination replyTo = request.getIn().getHeader("JMSReplyTo", Destination.class);
               
                assertEquals(EXPECTED_REPLY_HEADER, replyTo.toString());
               
                // send reply
                template.send("jms:dummy", ExchangePattern.InOnly, new Processor() {
View Full Code Here

    public void testPullRequestCommentProducer() throws Exception {
        PullRequest pullRequest = pullRequestService.addPullRequest("testPullRequestCommentProducer");
        latestPullRequestId = pullRequest.getId();

        Endpoint commentProducerEndpoint = getMandatoryEndpoint("direct:validPullRequest");
        Exchange exchange = commentProducerEndpoint.createExchange();
        String commentText = "Pushed this comment at " + new Date();
        exchange.getIn().setBody(commentText);
        template.send(commentProducerEndpoint, exchange);

        Thread.sleep(1 * 1000);

        // Verify that the mock pull request service received this comment.
View Full Code Here

        latestPullRequestId = pullRequest.getId();


        // Close it
        Endpoint closePullRequestEndpoint = getMandatoryEndpoint(PULL_REQUEST_PRODUCER_ENDPOINT);
        Exchange exchange = closePullRequestEndpoint.createExchange();
        template.send(closePullRequestEndpoint, exchange);

        Thread.sleep(1 * 1000);

        // Verify that it was closed
View Full Code Here

        @Override
        public void handleDelivery(String consumerTag, Envelope envelope,
                                   AMQP.BasicProperties properties, byte[] body) throws IOException {

            Exchange exchange = consumer.endpoint.createRabbitExchange(envelope, properties, body);
            mergeAmqpProperties(exchange, properties);

            boolean sendReply = properties.getReplyTo() != null;
            if (sendReply && !exchange.getPattern().isOutCapable()) {
                exchange.setPattern(ExchangePattern.InOut);
            }

            log.trace("Created exchange [exchange={}]", exchange);
            long deliveryTag = envelope.getDeliveryTag();
            try {
                consumer.getProcessor().process(exchange);
            } catch (Exception e) {
                exchange.setException(e);
            }

            if (!exchange.isFailed()) {
                // processing success
                if (sendReply && exchange.getPattern().isOutCapable()) {
                    Message msg;
                    if (exchange.hasOut()) {
                        msg = exchange.getOut();
                    } else {
                        msg = exchange.getIn();
                    }
                    AMQP.BasicProperties replyProps = new AMQP.BasicProperties.Builder()
                            .headers(msg.getHeaders())
                            .correlationId(properties.getCorrelationId())
                            .build();
                    channel.basicPublish("", properties.getReplyTo(), replyProps, msg.getBody(byte[].class));
                }
                if (!consumer.endpoint.isAutoAck()) {
                    log.trace("Acknowledging receipt [delivery_tag={}]", deliveryTag);
                    channel.basicAck(deliveryTag, false);
                }
            } else {
                // processing failed, then reject and handle the exception
                if (deliveryTag != 0 && !consumer.endpoint.isAutoAck()) {
                    channel.basicReject(deliveryTag, false);
                }
                if (exchange.getException() != null) {
                    getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
                }
            }
        }
View Full Code Here

        MockEndpoint resultEndpoint = context.getEndpoint("mock:encrypted", MockEndpoint.class);
        resultEndpoint.setExpectedMessageCount(1);
        context.start();
        sendText(fragment, context);
        resultEndpoint.assertIsSatisfied(100);
        Exchange exchange = resultEndpoint.getExchanges().get(0);
        Document inDoc = getDocumentForInMessage(exchange);
        if (log.isDebugEnabled()) {
            logMessage(exchange, inDoc);
        }
        Assert.assertTrue("The XML message has no encrypted data.", hasEncryptedData(inDoc));
View Full Code Here

        resultEndpoint.setExpectedMessageCount(1);
        // verify that the message was encrypted before checking that it is decrypted
        testEncryption(fragment, context);

        resultEndpoint.assertIsSatisfied(100);
        Exchange exchange = resultEndpoint.getExchanges().get(0);
        Document inDoc = getDocumentForInMessage(exchange);
        if (log.isDebugEnabled()) {
            logMessage(exchange, inDoc);
        }
        Assert.assertFalse("The XML message has encrypted data.", hasEncryptedData(inDoc));
View Full Code Here

TOP

Related Classes of org.apache.camel.Exchange

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.