Example usage for com.rabbitmq.client BuiltinExchangeType DIRECT

List of usage examples for com.rabbitmq.client BuiltinExchangeType DIRECT

Introduction

In this page you can find the example usage for com.rabbitmq.client BuiltinExchangeType DIRECT.

Prototype

BuiltinExchangeType DIRECT

To view the source code for com.rabbitmq.client BuiltinExchangeType DIRECT.

Click Source Link

Usage

From source file:org.apache.james.transport.mailets.amqp.AmqpRule.java

License:Apache License

@Override
protected void before() throws Throwable {
    amqpUri = "amqp://" + rabbitMqContainer.getIp();
    ConnectionFactory factory = new ConnectionFactory();
    factory.setUri(amqpUri);// ww w.ja v  a 2  s .co m
    waitingForRabbitToBeReady(factory);
    connection = factory.newConnection();
    channel = connection.createChannel();
    channel.exchangeDeclare(exchangeName, BuiltinExchangeType.DIRECT);
    queueName = channel.queueDeclare().getQueue();
    channel.queueBind(queueName, exchangeName, routingKey);
}

From source file:org.apache.james.transport.mailets.AmqpForwardAttachmentTest.java

License:Apache License

@Before
public void setup() throws Exception {
    @SuppressWarnings("deprecation")
    InetAddress containerIp = InetAddresses
            .forString(rabbitMqContainer.getContainerInfo().getNetworkSettings().getIpAddress());
    String amqpUri = "amqp://" + containerIp.getHostAddress();

    MailetContainer mailetContainer = MailetContainer.builder().postmaster("postmaster@" + JAMES_APACHE_ORG)
            .threads(5).addProcessor(CommonProcessors.root()).addProcessor(CommonProcessors.error())
            .addProcessor(ProcessorConfiguration.builder().state("transport").enableJmx(true)
                    .addMailet(MailetConfiguration.builder().match("All").clazz("RemoveMimeHeader")
                            .addProperty("name", "bcc").build())
                    .addMailet(MailetConfiguration.builder().match("All").clazz("StripAttachment")
                            .addProperty("attribute", MAIL_ATTRIBUTE).addProperty("pattern", ".*").build())
                    .addMailet(MailetConfiguration.builder().match("All").clazz("AmqpForwardAttribute")
                            .addProperty("uri", amqpUri).addProperty("exchange", EXCHANGE_NAME)
                            .addProperty("attribute", MAIL_ATTRIBUTE).addProperty("routing_key", ROUTING_KEY)
                            .build())/*ww w. j a  v a  2 s  .  c  o  m*/
                    .addMailet(MailetConfiguration.builder().match("RecipientIsLocal")
                            .clazz("org.apache.james.jmap.mailet.VacationMailet").build())
                    .addMailet(MailetConfiguration.builder().match("RecipientIsLocal").clazz("LocalDelivery")
                            .build())
                    .build())
            .build();

    jamesServer = new TemporaryJamesServer(temporaryFolder, mailetContainer);
    Duration slowPacedPollInterval = Duration.FIVE_HUNDRED_MILLISECONDS;
    calmlyAwait = Awaitility.with().pollInterval(slowPacedPollInterval).and().with()
            .pollDelay(slowPacedPollInterval).await();

    jamesServer.getServerProbe().addDomain(JAMES_APACHE_ORG);
    jamesServer.getServerProbe().addUser(FROM, PASSWORD);
    jamesServer.getServerProbe().addUser(RECIPIENT, PASSWORD);
    jamesServer.getServerProbe().createMailbox(MailboxConstants.USER_NAMESPACE, RECIPIENT, "INBOX");

    ConnectionFactory factory = new ConnectionFactory();
    factory.setUri(amqpUri);
    waitingForRabbitToBeReady(factory);
    connection = factory.newConnection();
    channel = connection.createChannel();
    channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.DIRECT);
    queueName = channel.queueDeclare().getQueue();
    channel.queueBind(queueName, EXCHANGE_NAME, ROUTING_KEY);
}