Search in sources :

Example 1 with ExchangeInfo

use of com.rabbitmq.http.client.domain.ExchangeInfo in project service-api by reportportal.

the class IndexerServiceClientImplTest method getExchanges.

private List<ExchangeInfo> getExchanges() {
    ExchangeInfo exchangeInfo = new ExchangeInfo();
    Map<String, Object> params = new HashMap<>();
    params.put(ANALYZER_PRIORITY, 0);
    params.put(ANALYZER_INDEX, true);
    exchangeInfo.setArguments(params);
    exchangeInfo.setName(AUTO_ANALYZER_KEY);
    return Lists.newArrayList(exchangeInfo);
}
Also used : HashMap(java.util.HashMap) ExchangeInfo(com.rabbitmq.http.client.domain.ExchangeInfo)

Example 2 with ExchangeInfo

use of com.rabbitmq.http.client.domain.ExchangeInfo in project service-api by reportportal.

the class ProjectControllerTest method indexProjectData.

@Test
void indexProjectData() throws Exception {
    ExchangeInfo exchangeInfo = new ExchangeInfo();
    exchangeInfo.setName("analyzer");
    HashMap<String, Object> arguments = new HashMap<>();
    arguments.put("analyzer_index", true);
    arguments.put("analyzer", "test_analyzer");
    exchangeInfo.setArguments(arguments);
    when(rabbitClient.getExchanges(any())).thenReturn(Collections.singletonList(exchangeInfo));
    mockMvc.perform(put("/v1/project/default_personal/index").with(token(oAuthHelper.getDefaultToken()))).andExpect(status().isOk());
}
Also used : ExchangeInfo(com.rabbitmq.http.client.domain.ExchangeInfo) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 3 with ExchangeInfo

use of com.rabbitmq.http.client.domain.ExchangeInfo in project spring-cloud-stream by spring-cloud.

the class RabbitBinderTests method testConsumerPropertiesWithUserInfrastructureCustomQueueArgs.

@Test
public void testConsumerPropertiesWithUserInfrastructureCustomQueueArgs() throws Exception {
    RabbitTestBinder binder = getBinder();
    ExtendedConsumerProperties<RabbitConsumerProperties> properties = createConsumerProperties();
    RabbitConsumerProperties extProps = properties.getExtension();
    extProps.setExchangeType(ExchangeTypes.DIRECT);
    extProps.setExchangeDurable(false);
    extProps.setExchangeAutoDelete(true);
    extProps.setBindingRoutingKey("foo");
    extProps.setExpires(30_000);
    extProps.setLazy(true);
    extProps.setMaxLength(10_000);
    extProps.setMaxLengthBytes(100_000);
    extProps.setMaxPriority(10);
    extProps.setOverflowBehavior("drop-head");
    extProps.setTtl(2_000);
    extProps.setAutoBindDlq(true);
    extProps.setDeadLetterQueueName("customDLQ");
    extProps.setDeadLetterExchange("customDLX");
    extProps.setDeadLetterExchangeType(ExchangeTypes.TOPIC);
    extProps.setDeadLetterRoutingKey("customDLRK");
    extProps.setDlqDeadLetterExchange("propsUser3");
    // GH-259 - if the next line was commented, the test failed.
    extProps.setDlqDeadLetterRoutingKey("propsUser3");
    extProps.setDlqExpires(60_000);
    extProps.setDlqLazy(true);
    extProps.setDlqMaxLength(20_000);
    extProps.setDlqMaxLengthBytes(40_000);
    extProps.setDlqOverflowBehavior("reject-publish");
    extProps.setDlqMaxPriority(8);
    extProps.setDlqTtl(1_000);
    extProps.setConsumerTagPrefix("testConsumerTag");
    extProps.setExclusive(true);
    Binding<MessageChannel> consumerBinding = binder.bindConsumer("propsUser3", "infra", createBindableChannel("input", new BindingProperties()), properties);
    Lifecycle endpoint = extractEndpoint(consumerBinding);
    SimpleMessageListenerContainer container = TestUtils.getPropertyValue(endpoint, "messageListenerContainer", SimpleMessageListenerContainer.class);
    assertThat(container.isRunning()).isTrue();
    Client client = new Client(adminUri());
    List<BindingInfo> bindings = client.getBindingsBySource("/", "propsUser3");
    int n = 0;
    while (n++ < 100 && bindings == null || bindings.size() < 1) {
        Thread.sleep(100);
        bindings = client.getBindingsBySource("/", "propsUser3");
    }
    assertThat(bindings.size()).isEqualTo(1);
    assertThat(bindings.get(0).getSource()).isEqualTo("propsUser3");
    assertThat(bindings.get(0).getDestination()).isEqualTo("propsUser3.infra");
    assertThat(bindings.get(0).getRoutingKey()).isEqualTo("foo");
    bindings = client.getBindingsBySource("/", "customDLX");
    n = 0;
    while (n++ < 100 && bindings == null || bindings.size() < 1) {
        Thread.sleep(100);
        bindings = client.getBindingsBySource("/", "customDLX");
    }
    // assertThat(bindings.size()).isEqualTo(1);
    assertThat(bindings.get(0).getSource()).isEqualTo("customDLX");
    assertThat(bindings.get(0).getDestination()).isEqualTo("customDLQ");
    assertThat(bindings.get(0).getRoutingKey()).isEqualTo("customDLRK");
    ExchangeInfo exchange = client.getExchange("/", "propsUser3");
    n = 0;
    while (n++ < 100 && exchange == null) {
        Thread.sleep(100);
        exchange = client.getExchange("/", "propsUser3");
    }
    assertThat(exchange.getType()).isEqualTo("direct");
    assertThat(exchange.isDurable()).isEqualTo(false);
    assertThat(exchange.isAutoDelete()).isEqualTo(true);
    exchange = client.getExchange("/", "customDLX");
    n = 0;
    while (n++ < 100 && exchange == null) {
        Thread.sleep(100);
        exchange = client.getExchange("/", "customDLX");
    }
    assertThat(exchange.getType()).isEqualTo("topic");
    assertThat(exchange.isDurable()).isEqualTo(true);
    assertThat(exchange.isAutoDelete()).isEqualTo(false);
    QueueInfo queue = client.getQueue("/", "propsUser3.infra");
    n = 0;
    while (n++ < 100 && queue == null || queue.getConsumerCount() == 0) {
        Thread.sleep(100);
        queue = client.getQueue("/", "propsUser3.infra");
    }
    assertThat(queue).isNotNull();
    Map<String, Object> args = queue.getArguments();
    assertThat(args.get("x-expires")).isEqualTo(30_000);
    assertThat(args.get("x-max-length")).isEqualTo(10_000);
    assertThat(args.get("x-max-length-bytes")).isEqualTo(100_000);
    assertThat(args.get("x-overflow")).isEqualTo("drop-head");
    assertThat(args.get("x-max-priority")).isEqualTo(10);
    assertThat(args.get("x-message-ttl")).isEqualTo(2_000);
    assertThat(args.get("x-dead-letter-exchange")).isEqualTo("customDLX");
    assertThat(args.get("x-dead-letter-routing-key")).isEqualTo("customDLRK");
    assertThat(args.get("x-queue-mode")).isEqualTo("lazy");
    assertThat(queue.getExclusiveConsumerTag()).isEqualTo("testConsumerTag#0");
    queue = client.getQueue("/", "customDLQ");
    n = 0;
    while (n++ < 100 && queue == null) {
        Thread.sleep(100);
        queue = client.getQueue("/", "customDLQ");
    }
    assertThat(queue).isNotNull();
    args = queue.getArguments();
    assertThat(args.get("x-expires")).isEqualTo(60_000);
    assertThat(args.get("x-max-length")).isEqualTo(20_000);
    assertThat(args.get("x-max-length-bytes")).isEqualTo(40_000);
    assertThat(args.get("x-overflow")).isEqualTo("reject-publish");
    assertThat(args.get("x-max-priority")).isEqualTo(8);
    assertThat(args.get("x-message-ttl")).isEqualTo(1_000);
    assertThat(args.get("x-dead-letter-exchange")).isEqualTo("propsUser3");
    assertThat(args.get("x-dead-letter-routing-key")).isEqualTo("propsUser3");
    assertThat(args.get("x-queue-mode")).isEqualTo("lazy");
    consumerBinding.unbind();
    assertThat(container.isRunning()).isFalse();
    verifyAutoDeclareContextClear(binder);
}
Also used : QueueInfo(com.rabbitmq.http.client.domain.QueueInfo) RabbitConsumerProperties(org.springframework.cloud.stream.binder.rabbit.properties.RabbitConsumerProperties) BindingProperties(org.springframework.cloud.stream.config.BindingProperties) Lifecycle(org.springframework.context.Lifecycle) SimpleMessageListenerContainer(org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer) LongString(com.rabbitmq.client.LongString) ExchangeInfo(com.rabbitmq.http.client.domain.ExchangeInfo) AmqpOutboundEndpoint(org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint) MessageChannel(org.springframework.messaging.MessageChannel) BindingInfo(com.rabbitmq.http.client.domain.BindingInfo) Client(com.rabbitmq.http.client.Client) Test(org.junit.jupiter.api.Test)

Example 4 with ExchangeInfo

use of com.rabbitmq.http.client.domain.ExchangeInfo in project spring-cloud-stream by spring-cloud.

the class RabbitBinderModuleTests method checkCustomizedArgs.

private void checkCustomizedArgs() throws MalformedURLException, URISyntaxException, InterruptedException {
    Client client = new Client(String.format("http://guest:guest@localhost:%d/api", RABBITMQ.getHttpPort()));
    List<BindingInfo> bindings = client.getBindingsBySource("/", "process-in-0");
    int n = 0;
    while (n++ < 100 && bindings == null || bindings.size() < 1) {
        Thread.sleep(100);
        bindings = client.getBindingsBySource("/", "process-in-0");
    }
    assertThat(bindings).isNotNull();
    assertThat(bindings.get(0).getArguments()).contains(entry("added.by", "customizer"));
    ExchangeInfo exchange = client.getExchange("/", "process-in-0");
    assertThat(exchange.getArguments()).contains(entry("added.by", "customizer"));
    QueueInfo queue = client.getQueue("/", bindings.get(0).getDestination());
    assertThat(queue.getArguments()).contains(entry("added.by", "customizer"));
    assertThat(queue.getArguments()).contains(entry("x-single-active-consumer", Boolean.TRUE));
}
Also used : QueueInfo(com.rabbitmq.http.client.domain.QueueInfo) BindingInfo(com.rabbitmq.http.client.domain.BindingInfo) Client(com.rabbitmq.http.client.Client) ExchangeInfo(com.rabbitmq.http.client.domain.ExchangeInfo) AmqpOutboundEndpoint(org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint)

Example 5 with ExchangeInfo

use of com.rabbitmq.http.client.domain.ExchangeInfo in project spring-amqp by spring-projects.

the class FixedReplyQueueDeadLetterTests method testQueueArgs3.

@Test
void testQueueArgs3() throws MalformedURLException, URISyntaxException, InterruptedException {
    Client client = new Client(brokerRunning.getAdminUri(), brokerRunning.getAdminUser(), brokerRunning.getAdminPassword());
    QueueInfo queue = await().until(() -> client.getQueue("/", "all.args.3"), que -> que != null);
    Map<String, Object> arguments = queue.getArguments();
    assertThat(arguments.get("x-message-ttl")).isEqualTo(1000);
    assertThat(arguments.get("x-expires")).isEqualTo(200_000);
    assertThat(arguments.get("x-max-length")).isEqualTo(42);
    assertThat(arguments.get("x-max-length-bytes")).isEqualTo(10_000);
    assertThat(arguments.get("x-overflow")).isEqualTo("reject-publish");
    assertThat(arguments.get("x-dead-letter-exchange")).isEqualTo("reply.dlx");
    assertThat(arguments.get("x-dead-letter-routing-key")).isEqualTo("reply.dlrk");
    assertThat(arguments.get("x-max-priority")).isEqualTo(4);
    assertThat(arguments.get("x-queue-mode")).isEqualTo("lazy");
    assertThat(arguments.get(Queue.X_QUEUE_LEADER_LOCATOR)).isEqualTo(LeaderLocator.random.getValue());
    ExchangeInfo exchange = client.getExchange("/", "dlx.test.requestEx");
    assertThat(exchange.getArguments().get("alternate-exchange")).isEqualTo("alternate");
}
Also used : QueueInfo(com.rabbitmq.http.client.domain.QueueInfo) Client(com.rabbitmq.http.client.Client) ExchangeInfo(com.rabbitmq.http.client.domain.ExchangeInfo) Test(org.junit.jupiter.api.Test)

Aggregations

ExchangeInfo (com.rabbitmq.http.client.domain.ExchangeInfo)14 Test (org.junit.jupiter.api.Test)12 Client (com.rabbitmq.http.client.Client)4 DirectExchange (org.springframework.amqp.core.DirectExchange)4 BindingInfo (com.rabbitmq.http.client.domain.BindingInfo)3 QueueInfo (com.rabbitmq.http.client.domain.QueueInfo)3 AmqpOutboundEndpoint (org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint)3 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)2 LongString (com.rabbitmq.client.LongString)2 Exchange (org.springframework.amqp.core.Exchange)2 SimpleMessageListenerContainer (org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer)2 RabbitConsumerProperties (org.springframework.cloud.stream.binder.rabbit.properties.RabbitConsumerProperties)2 BindingProperties (org.springframework.cloud.stream.config.BindingProperties)2 Lifecycle (org.springframework.context.Lifecycle)2 MessageChannel (org.springframework.messaging.MessageChannel)2 HashMap (java.util.HashMap)1 AmqpIOException (org.springframework.amqp.AmqpIOException)1 AbstractExchange (org.springframework.amqp.core.AbstractExchange)1 AnonymousQueue (org.springframework.amqp.core.AnonymousQueue)1 Binding (org.springframework.amqp.core.Binding)1