Search in sources :

Example 86 with MapBasedConfig

use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class JmsConnectorTest method testWithStringAndSessionModel.

@Test
public void testWithStringAndSessionModel() {
    Map<String, Object> map = new HashMap<>();
    map.put("mp.messaging.outgoing.queue-one.connector", JmsConnector.CONNECTOR_NAME);
    map.put("mp.messaging.incoming.jms.connector", JmsConnector.CONNECTOR_NAME);
    map.put("mp.messaging.incoming.jms.destination", "queue-one");
    map.put("mp.messaging.incoming.jms.session-mode", "DUPS_OK_ACKNOWLEDGE");
    MapBasedConfig config = new MapBasedConfig(map);
    addConfig(config);
    WeldContainer container = deploy(PayloadConsumerBean.class, ProducerBean.class);
    PayloadConsumerBean bean = container.select(PayloadConsumerBean.class).get();
    await().until(() -> bean.list().size() > 3);
    assertThat(bean.list()).hasSizeGreaterThan(3);
}
Also used : WeldContainer(org.jboss.weld.environment.se.WeldContainer) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 87 with MapBasedConfig

use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class JmsConnectorTest method testWithInvalidIncomingDestinationType.

@Test
public void testWithInvalidIncomingDestinationType() {
    Map<String, Object> map = new HashMap<>();
    map.put("mp.messaging.outgoing.queue-one.connector", JmsConnector.CONNECTOR_NAME);
    map.put("mp.messaging.incoming.jms.connector", JmsConnector.CONNECTOR_NAME);
    map.put("mp.messaging.incoming.jms.destination-type", "invalid");
    MapBasedConfig config = new MapBasedConfig(map);
    addConfig(config);
    assertThatThrownBy(() -> deploy(PayloadConsumerBean.class, ProducerBean.class)).isInstanceOf(DeploymentException.class);
}
Also used : MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 88 with MapBasedConfig

use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class JmsSinkTest method testDefaultConfigurationAgainstTopic.

@Test
public void testDefaultConfigurationAgainstTopic() throws JMSException {
    MapBasedConfig config = new MapBasedConfig().with("destination", "my-topic").with("destination-type", "topic").with("channel-name", "jms");
    JmsSink sink = new JmsSink(jms, new JmsConnectorOutgoingConfiguration(config), jsonMapping, executor);
    MyJmsClient client1 = new MyJmsClient(jms.createTopic("my-topic"));
    MyJmsClient client2 = new MyJmsClient(jms.createTopic("my-topic"));
    subscriber = sink.getSink().build();
    subscriber.onSubscribe(new Subscriptions.EmptySubscription());
    AtomicBoolean acked = new AtomicBoolean();
    subscriber.onNext(Message.of("hello", () -> CompletableFuture.runAsync(() -> acked.set(true))));
    await().until(() -> client1.messages.size() >= 1);
    await().until(() -> client2.messages.size() >= 1);
    assertThat(acked).isTrue();
    assertThat(client1.messages.get(0).getBody(String.class)).isEqualTo("hello");
    assertThat(client2.messages.get(0).getBody(String.class)).isEqualTo("hello");
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Subscriptions(io.smallrye.mutiny.helpers.Subscriptions) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 89 with MapBasedConfig

use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class JmsSinkTest method testWithDeliveryDelayAndMode.

@Test
public void testWithDeliveryDelayAndMode() throws JMSException {
    MapBasedConfig config = new MapBasedConfig().with("destination", "queue-one").with("delivery-delay", 1500L).with("delivery-mode", "non_persistent").with("channel-name", "jms");
    JmsSink sink = new JmsSink(jms, new JmsConnectorOutgoingConfiguration(config), jsonMapping, executor);
    MyJmsClient client = new MyJmsClient(jms.createQueue("queue-one"));
    subscriber = sink.getSink().build();
    subscriber.onSubscribe(new Subscriptions.EmptySubscription());
    AtomicBoolean acked = new AtomicBoolean();
    subscriber.onNext(Message.of("hello", () -> CompletableFuture.runAsync(() -> acked.set(true))));
    await().atLeast(1, TimeUnit.SECONDS).until(() -> client.messages.size() >= 1);
    assertThat(acked).isTrue();
    assertThat(client.messages.get(0).getBody(String.class)).isEqualTo("hello");
    assertThat(client.messages.get(0).getJMSMessageID()).isNotNull();
    assertThat(client.messages.get(0).getJMSTimestamp()).isPositive();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Subscriptions(io.smallrye.mutiny.helpers.Subscriptions) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Example 90 with MapBasedConfig

use of io.smallrye.reactive.messaging.test.common.config.MapBasedConfig in project smallrye-reactive-messaging by smallrye.

the class JmsSinkTest method testWithReplyToTopic.

@SuppressWarnings("ConstantConditions")
@Test
public void testWithReplyToTopic() throws JMSException {
    MapBasedConfig config = new MapBasedConfig().with("destination", "queue-one").with("reply-to", "my-response").with("reply-to-destination-type", "topic").with("channel-name", "jms");
    JmsSink sink = new JmsSink(jms, new JmsConnectorOutgoingConfiguration(config), jsonMapping, executor);
    MyJmsClient client = new MyJmsClient(jms.createQueue("queue-one"));
    subscriber = sink.getSink().build();
    subscriber.onSubscribe(new Subscriptions.EmptySubscription());
    AtomicBoolean acked = new AtomicBoolean();
    subscriber.onNext(Message.of("hello", () -> CompletableFuture.runAsync(() -> acked.set(true))));
    await().until(() -> client.messages.size() >= 1);
    assertThat(acked).isTrue();
    assertThat(client.messages.get(0).getBody(String.class)).isEqualTo("hello");
    assertThat(client.messages.get(0).getJMSReplyTo()).isInstanceOf(Topic.class);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Subscriptions(io.smallrye.mutiny.helpers.Subscriptions) MapBasedConfig(io.smallrye.reactive.messaging.test.common.config.MapBasedConfig) Test(org.junit.jupiter.api.Test)

Aggregations

MapBasedConfig (io.smallrye.reactive.messaging.test.common.config.MapBasedConfig)272 Test (org.junit.jupiter.api.Test)223 Message (org.eclipse.microprofile.reactive.messaging.Message)69 JsonObject (io.vertx.core.json.JsonObject)63 ArrayList (java.util.ArrayList)61 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)57 TopicPartition (org.apache.kafka.common.TopicPartition)43 Awaitility.await (org.awaitility.Awaitility.await)38 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)37 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)34 Weld (org.jboss.weld.environment.se.Weld)32 KafkaMapBasedConfig (io.smallrye.reactive.messaging.kafka.base.KafkaMapBasedConfig)31 HashMap (java.util.HashMap)29 AfterEach (org.junit.jupiter.api.AfterEach)29 Collectors (java.util.stream.Collectors)28 HealthReport (io.smallrye.reactive.messaging.health.HealthReport)26 KafkaSource (io.smallrye.reactive.messaging.kafka.impl.KafkaSource)26 IntegerDeserializer (org.apache.kafka.common.serialization.IntegerDeserializer)25 ProducerRecord (org.apache.kafka.clients.producer.ProducerRecord)23 Duration (java.time.Duration)22