com.rabbitmq.client.BuiltinExchangeType Java Examples
The following examples show how to use
com.rabbitmq.client.BuiltinExchangeType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueueConfig.java From flow-platform-x with Apache License 2.0 | 6 votes |
@Bean public RabbitQueueOperation deadLetterQueueManager(Connection rabbitConnection) throws IOException { String name = rabbitProperties.getJobDlQueue(); String exchange = rabbitProperties.getJobDlExchange(); RabbitQueueOperation manager = new RabbitQueueOperation(rabbitConnection, 1, name); manager.declare(true); Map<String, Object> props = new HashMap<>(0); Channel channel = manager.getChannel(); channel.exchangeDeclare(exchange, BuiltinExchangeType.DIRECT, true, false, props); channel.queueBind(manager.getQueueName(), exchange, JobDlRoutingKey); return manager; }
Example #2
Source File: ExchangeTest.java From rabbitmq-mock with Apache License 2.0 | 6 votes |
@ParameterizedTest(name = "{0} matching any headers '{'os: 'linux', cores: '8''}': {1}") @CsvSource({ "'', false", "'os, linux', true", "'cores, 8', true", "'os, linux, cores, 4', true", "'os, linux, cores, 8', true", "'os, ios, cores, 8', true", }) void headers_topic_with_x_match_any_matches_if_one_header_is_matching(String headers, boolean matches) { MultipleReceiverExchange headersExchange = (MultipleReceiverExchange) mockExchangeFactory.build("test", BuiltinExchangeType.HEADERS.getType(), empty(), mock(ReceiverRegistry.class)); BindConfiguration bindConfiguration = new BindConfiguration("unused", null, map("os", "linux", "cores", "8", "x-match", "any")); assertThat(headersExchange.match(bindConfiguration, "unused", map(headers.split(",\\s*")))).isEqualTo(matches); }
Example #3
Source File: ExchangeTest.java From rabbitmq-mock with Apache License 2.0 | 6 votes |
@ParameterizedTest(name = "{1} matches {0} as fanout bindingKey") @CsvSource({ "some.key, some.key", "some.other.key, some.other.key", "some.key, other.key", "*.orange.*, quick.orange.rabbit", "lazy.#, lazy.pink.rabbit", "some.key, other.key", "*.orange.*, lazy.pink.rabbit", "*.orange.*, quick.orange.male.rabbit", "*.*.rabbit, quick.orange.fox", "*.*.rabbit, quick.orange.male.rabbit", "lazy.#, quick.brown.fox" }) void binding_key_matches_routing_key(String bindingKey, String routingKey) { MultipleReceiverExchange fanoutExchange = (MultipleReceiverExchange) mockExchangeFactory.build("test", BuiltinExchangeType.FANOUT.getType(), empty(), mock(ReceiverRegistry.class)); BindConfiguration bindConfiguration = new BindConfiguration(bindingKey, null, emptyMap()); assertThat(fanoutExchange.match(bindConfiguration, routingKey, emptyMap())).isTrue(); }
Example #4
Source File: ProducerExchangeConsumer_Fanout.java From util4j with Apache License 2.0 | 6 votes |
public void producer() throws Exception{ //1、获取连接 Connection connection = RabbitMqConnectionFactoy.getConnection(); //2、声明信道 Channel channel = connection.createChannel(); //3、声明(创建)交换机 channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.FANOUT); Thread.sleep(3000); //4、定义消息内容(发布多条消息) for(int i = 0 ; i < 10 ; i++){ String message = "hello rabbitmq "+i; //定义消息头 Map<String,Object> header=new HashMap<>(); header.put("i",i); BasicProperties bp=new BasicProperties.Builder().headers(header).build(); //5、发布消息 channel.basicPublish(EXCHANGE_NAME,"",bp,message.getBytes()); System.out.println("[x] Sent'"+message+"'"); //模拟发送消息延时,便于演示多个消费者竞争接受消息 // Thread.sleep(i*10); } //6、关闭通道 channel.close(); //7、关闭连接 connection.close(); }
Example #5
Source File: QueueConfig.java From flow-platform-x with Apache License 2.0 | 6 votes |
@Bean("logQueueManager") public RabbitOperations logQueueManager(Connection rabbitConnection, String shellLogQueue, String ttyLogQueue) throws IOException { RabbitOperations manager = new RabbitOperations(rabbitConnection, 10); manager.declareTemp(shellLogQueue); manager.declareExchangeAndBind( rabbitProperties.getShellLogEx(), BuiltinExchangeType.FANOUT, shellLogQueue, StringHelper.EMPTY ); manager.declareTemp(ttyLogQueue); manager.declareExchangeAndBind( rabbitProperties.getTtyLogEx(), BuiltinExchangeType.FANOUT, ttyLogQueue, StringHelper.EMPTY ); return manager; }
Example #6
Source File: ChannelTest.java From rabbitmq-mock with Apache License 2.0 | 6 votes |
@Test void queueUnbind_removes_binding() throws IOException, TimeoutException { try (Connection conn = new MockConnectionFactory().newConnection()) { try (Channel channel = conn.createChannel()) { assertThat(channel.exchangeDeclare("ex-test", BuiltinExchangeType.FANOUT)).isNotNull(); assertThat(channel.queueDeclare()).isNotNull(); channel.queueBindNoWait("", "ex-test", "some.key", null); channel.basicPublish("ex-test", "unused", null, "test message".getBytes()); assertThat(channel.basicGet("", false)).isNotNull(); assertThat(channel.queueUnbind("", "ex-test", "some.key")).isNotNull(); channel.basicPublish("ex-test", "unused", null, "test message".getBytes()); assertThat(channel.basicGet("", false)).isNull(); } } }
Example #7
Source File: ChannelTest.java From rabbitmq-mock with Apache License 2.0 | 6 votes |
@Test void exchangeUnbindNoWait_removes_binding() throws IOException, TimeoutException { try (Connection conn = new MockConnectionFactory().newConnection()) { try (Channel channel = conn.createChannel()) { assertThat(channel.exchangeDeclare("ex-from", BuiltinExchangeType.FANOUT)).isNotNull(); assertThat(channel.exchangeDeclare("ex-to", BuiltinExchangeType.FANOUT)).isNotNull(); assertThat(channel.queueDeclare()).isNotNull(); channel.exchangeBindNoWait("ex-to", "ex-from", "test.key", null); assertThat(channel.queueBind("", "ex-to", "queue.used")).isNotNull(); channel.exchangeUnbindNoWait("ex-to", "ex-from", "test.key", null); channel.basicPublish("ex-from", "unused", null, "test message".getBytes()); GetResponse response = channel.basicGet("", true); assertThat(response).isNull(); } } }
Example #8
Source File: ChannelTest.java From rabbitmq-mock with Apache License 2.0 | 6 votes |
@Test void exchangeUnbind_removes_binding() throws IOException, TimeoutException { try (Connection conn = new MockConnectionFactory().newConnection()) { try (Channel channel = conn.createChannel()) { assertThat(channel.exchangeDeclare("ex-from", BuiltinExchangeType.FANOUT)).isNotNull(); assertThat(channel.exchangeDeclare("ex-to", BuiltinExchangeType.FANOUT)).isNotNull(); assertThat(channel.queueDeclare()).isNotNull(); channel.exchangeBindNoWait("ex-to", "ex-from", "test.key", null); assertThat(channel.queueBind("", "ex-to", "queue.used")).isNotNull(); assertThat(channel.exchangeUnbind("ex-to", "ex-from", "test.key")).isNotNull(); channel.basicPublish("ex-from", "unused", null, "test message".getBytes()); GetResponse response = channel.basicGet("", true); assertThat(response).isNull(); } } }
Example #9
Source File: ChannelTest.java From rabbitmq-mock with Apache License 2.0 | 6 votes |
@Test void exchangeBindNoWait_binds_two_exchanges() throws IOException, TimeoutException { try (Connection conn = new MockConnectionFactory().newConnection()) { try (Channel channel = conn.createChannel()) { assertThat(channel.exchangeDeclare("ex-from", BuiltinExchangeType.FANOUT)).isNotNull(); assertThat(channel.exchangeDeclare("ex-to", BuiltinExchangeType.FANOUT)).isNotNull(); assertThat(channel.queueDeclare()).isNotNull(); channel.exchangeBindNoWait("ex-to", "ex-from", "test.key", null); assertThat(channel.queueBind("", "ex-to", "queue.used")).isNotNull(); channel.basicPublish("ex-from", "unused", null, "test message".getBytes()); GetResponse response = channel.basicGet("", true); assertThat(response).isNotNull(); assertThat(new String(response.getBody())).isEqualTo("test message"); } } }
Example #10
Source File: ChannelTest.java From rabbitmq-mock with Apache License 2.0 | 6 votes |
@Test void exchangeBind_binds_two_exchanges() throws IOException, TimeoutException { try (Connection conn = new MockConnectionFactory().newConnection()) { try (Channel channel = conn.createChannel()) { assertThat(channel.exchangeDeclare("ex-from", BuiltinExchangeType.FANOUT)).isNotNull(); assertThat(channel.exchangeDeclare("ex-to", BuiltinExchangeType.FANOUT)).isNotNull(); assertThat(channel.queueDeclare()).isNotNull(); assertThat(channel.exchangeBind("ex-to", "ex-from", "test.key")).isNotNull(); assertThat(channel.queueBind("", "ex-to", "queue.used")).isNotNull(); channel.basicPublish("ex-from", "unused", null, "test message".getBytes()); GetResponse response = channel.basicGet("", false); assertThat(response).isNotNull(); assertThat(new String(response.getBody())).isEqualTo("test message"); } } }
Example #11
Source File: ComplexUseCasesTests.java From rabbitmq-mock with Apache License 2.0 | 6 votes |
@Test void expired_message_should_be_consumable_after_being_dead_lettered() throws IOException, TimeoutException, InterruptedException { try (Connection conn = new MockConnectionFactory().newConnection()) { try (Channel channel = conn.createChannel()) { channel.exchangeDeclare("rejected-ex", BuiltinExchangeType.FANOUT); channel.queueDeclare("rejected", true, false, false, null); channel.queueBindNoWait("rejected", "rejected-ex", "unused", null); queue("fruits").withMessageTtl(10L).withDeadLetterExchange("rejected-ex").declare(channel); List<String> messages = new ArrayList<>(); channel.basicConsume("rejected", new DefaultConsumer(channel) { @Override public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) { messages.add(new String(body)); } }); channel.basicPublish("", "fruits", null, "banana".getBytes()); TimeUnit.MILLISECONDS.sleep(100L); assertThat(messages).hasSize(1); } } }
Example #12
Source File: DifferPublisher.java From EDDI with Apache License 2.0 | 6 votes |
@Override public void init(DeliverCallback conversationCreatedCallback, DeliverCallback messageCreatedCallback) { try { channel = channelProvider.get(); channel.exchangeDeclare(EDDI_EXCHANGE, BuiltinExchangeType.TOPIC, true, false, null); channel.queueDeclare(CONVERSATION_CREATED_QUEUE_NAME, true, false, false, null); channel.queueBind(CONVERSATION_CREATED_QUEUE_NAME, CONVERSATION_CREATED_EXCHANGE, ""); channel.basicConsume(CONVERSATION_CREATED_QUEUE_NAME, false, conversationCreatedCallback, cancelCallback); channel.queueDeclare(MESSAGE_CREATED_QUEUE_NAME, true, false, false, null); channel.queueBind(MESSAGE_CREATED_QUEUE_NAME, MESSAGE_CREATED_EXCHANGE, ""); channel.basicConsume(MESSAGE_CREATED_QUEUE_NAME, false, messageCreatedCallback, cancelCallback); channel.queueDeclare(MESSAGE_CREATED_EDDI_FAILED_ROUTING_KEY, true, false, false, null); channel.queueBind(MESSAGE_CREATED_EDDI_FAILED_ROUTING_KEY, EDDI_EXCHANGE, ""); channel.confirmSelect(); } catch (IOException e) { log.error(e.getLocalizedMessage(), e); } }
Example #13
Source File: RabbitMQSink.java From pulsar with Apache License 2.0 | 6 votes |
@Override public void open(Map<String, Object> config, SinkContext sinkContext) throws Exception { rabbitMQSinkConfig = RabbitMQSinkConfig.load(config); rabbitMQSinkConfig.validate(); ConnectionFactory connectionFactory = rabbitMQSinkConfig.createConnectionFactory(); rabbitMQConnection = connectionFactory.newConnection(rabbitMQSinkConfig.getConnectionName()); log.info("A new connection to {}:{} has been opened successfully.", rabbitMQConnection.getAddress().getCanonicalHostName(), rabbitMQConnection.getPort() ); exchangeName = rabbitMQSinkConfig.getExchangeName(); defaultRoutingKey = rabbitMQSinkConfig.getRoutingKey(); String exchangeType = rabbitMQSinkConfig.getExchangeType(); rabbitMQChannel = rabbitMQConnection.createChannel(); String queueName = rabbitMQSinkConfig.getQueueName(); if (StringUtils.isNotEmpty(queueName)) { rabbitMQChannel.exchangeDeclare(exchangeName, BuiltinExchangeType.DIRECT, true); rabbitMQChannel.queueDeclare(rabbitMQSinkConfig.getQueueName(), true, false, false, null); rabbitMQChannel.queueBind(rabbitMQSinkConfig.getQueueName(), exchangeName, defaultRoutingKey); } else { rabbitMQChannel.exchangeDeclare(exchangeName, exchangeType, true); } }
Example #14
Source File: RabbitMQSourceTester.java From pulsar with Apache License 2.0 | 6 votes |
@Override public Map<String, String> produceSourceMessages(int numMessages) throws Exception { ConnectionFactory connectionFactory = createConnectionFactory(serviceContainer); try (Connection connection = connectionFactory.newConnection("rabbitmq-source-tester"); Channel channel = connection.createChannel()) { // the queue declaration has to be aligned with that in RabbitMQSource channel.queueDeclare(queueName, false, false, false, null); // use topic mode exchange in order to publish messages with any keys channel.exchangeDeclare(exchangeName, BuiltinExchangeType.TOPIC); channel.queueBind(queueName, exchangeName, "#"); Map<String, String> values = new LinkedHashMap<>(); for (int i = 0; i < numMessages; i++) { String key = "rb-key-" + i; String value = "rb-value-" + i; values.put(key, value); channel.basicPublish(exchangeName, key, null, value.getBytes()); } return values; } }
Example #15
Source File: QueueConfig.java From flow-platform-x with Apache License 2.0 | 5 votes |
@Bean("jobsQueueManager") public RabbitOperations jobsQueueManager(Connection rabbitConnection) throws IOException { RabbitOperations manager = new RabbitOperations(rabbitConnection, 1); // setup dead letter queue String queue = rabbitProperties.getJobDlQueue(); manager.declare(queue, true); Map<String, Object> args = new HashMap<>(0); String exchange = rabbitProperties.getJobDlExchange(); manager.declareExchangeAndBind(exchange, BuiltinExchangeType.DIRECT, true, false, args, queue, JobDlRoutingKey); return manager; }
Example #16
Source File: RabbitMqReceiver.java From tangyuan2 with GNU General Public License v3.0 | 5 votes |
private void recvTopicMessage() throws Throwable { String exchange = queue.getName(); // String exchangeType = (String) queue.getProperties().get(RabbitMqVo.RABBITMQ_EXCHANGE_TYPE); // final boolean autoAck = (Boolean) queue.getProperties().get(RabbitMqVo.RABBITMQ_AUTOACK); String exchangeType = queue.getExchangeType(); final boolean autoAck = queue.isAutoAck(); // RabbitMqSource mqSource = (RabbitMqSource) MqContainer.getInstance().getMqSourceManager().getMqSource(queue.getMsKey()); mqSource = (RabbitMqSource) MqContainer.getInstance().getMqSourceManager().getMqSource(queue.getMsKey()); channel = mqSource.getChannel(); channel.exchangeDeclare(exchange, exchangeType); String queueName = channel.queueDeclare().getQueue(); if (BuiltinExchangeType.FANOUT.getType().equalsIgnoreCase(exchangeType)) { channel.queueBind(queueName, exchange, ""); } else { if (null == binding) { throw new TangYuanException("exchange[" + exchange + "], the binding is empty."); } List<BindingPattern> patterns = binding.getPatterns(); if (null == patterns || 0 == patterns.size()) { throw new TangYuanException("exchange[" + exchange + "], the binding is empty."); } for (BindingPattern bp : patterns) { channel.queueBind(queueName, exchange, bp.getPattern()); } } // channel.basicQos(prefetchCount);// TODO running = true; // boolean asynReceiveMessages = (Boolean) queue.getProperties().get(RabbitMqVo.RABBITMQ_C_ASYNRECEIVEMESSAGES); boolean asynReceiveMessages = queue.isAsynReceive(); recv(asynReceiveMessages, queueName, autoAck, null); }
Example #17
Source File: RabbitMqBenchmarkDriver.java From openmessaging-benchmark with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<BenchmarkProducer> createProducer(String topic) { Channel channel = null; try { channel = connection.createChannel(); channel.exchangeDeclare(topic, BuiltinExchangeType.FANOUT); channel.confirmSelect(); } catch (IOException e) { e.printStackTrace(); } return CompletableFuture.completedFuture(new RabbitMqBenchmarkProducer(channel, topic, config.messagePersistence)); }
Example #18
Source File: ProducerExchangeConsumer_Topic.java From util4j with Apache License 2.0 | 5 votes |
public void producer() throws Exception{ //1、获取连接 Connection connection = RabbitMqConnectionFactoy.getConnection(); //2、声明信道 Channel channel = connection.createChannel(); //3、声明(创建)交换机 channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.TOPIC); Thread.sleep(3000); //4、定义消息内容(发布多条消息) for(int i = 0 ; i < 10 ; i++){ String message = "hello rabbitmq "+i; //定义消息头 Map<String,Object> header=new HashMap<>(); header.put("i",i); BasicProperties bp=new BasicProperties.Builder().headers(header).build(); //5、发布消息 if(i%2!=0) {//单数进key1的队列 channel.basicPublish(EXCHANGE_NAME,"test.a",bp,message.getBytes()); }else {//偶数进key2的队列 channel.basicPublish(EXCHANGE_NAME,"test.b",bp,message.getBytes()); } System.out.println("[x] Sent'"+message+"'"); //模拟发送消息延时,便于演示多个消费者竞争接受消息 Thread.sleep(i*10); } //6、关闭通道 channel.close(); //7、关闭连接 connection.close(); }
Example #19
Source File: ExchangeDeclarationTest.java From rabbitmq-cdi with MIT License | 5 votes |
@Test void testToString() { ExchangeDeclaration sut = new ExchangeDeclaration("hello"); sut.withType(BuiltinExchangeType.DIRECT); sut.withAutoDelete(true); sut.withDurable(true); sut.withArgument("key","value"); String result = sut.toString(); System.out.println(result); assertEquals("exchange declaration for exchangeName='hello', exchangeType='direct', durable=true, autoDelete=true, arguments={key=value}",result); }
Example #20
Source File: ProducerExchangeConsumer_Direct.java From util4j with Apache License 2.0 | 5 votes |
public void producer() throws Exception{ //1、获取连接 Connection connection = RabbitMqConnectionFactoy.getConnection(); //2、声明信道 Channel channel = connection.createChannel(); //3、声明(创建)交换机 channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.DIRECT); //4、定义消息内容(发布多条消息) Thread.sleep(3000); for(int i = 0 ; i < 6 ; i++){ String message = "hello rabbitmq "+i; //定义消息头 Map<String,Object> header=new HashMap<>(); header.put("i",i); BasicProperties bp=new BasicProperties.Builder().headers(header).build(); //5、发布消息 if(i%2!=0) {//单数进key1的队列 channel.basicPublish(EXCHANGE_NAME,ROUTER_KEY_1,bp,message.getBytes()); }else {//偶数进key2的队列 channel.basicPublish(EXCHANGE_NAME,ROUTER_KEY_2,bp,message.getBytes()); channel.basicPublish(EXCHANGE_NAME,ROUTER_KEY_22,bp,message.getBytes()); } System.out.println("[x] Sent'"+message+"'"); //模拟发送消息延时,便于演示多个消费者竞争接受消息 // Thread.sleep(i*10); } //6、关闭通道 channel.close(); //7、关闭连接 connection.close(); }
Example #21
Source File: ChannelPoolListener.java From vlingo-examples with Mozilla Public License 2.0 | 5 votes |
@Override public void initialize(final Channel channel) throws IOException { mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); channel.exchangeDeclare("order", BuiltinExchangeType.DIRECT, true); channel.queueDeclare("registered-order", true, false, false, null); channel.queueBind("registered-order", "order", "registered-order"); }
Example #22
Source File: QueueConfig.java From flow-platform-x with Apache License 2.0 | 5 votes |
@Bean public RabbitQueueOperation loggingQueueManager(Connection rabbitConnection) throws IOException { String name = rabbitProperties.getLoggingQueue(); String exchange = rabbitProperties.getLoggingExchange(); RabbitQueueOperation manager = new RabbitQueueOperation(rabbitConnection, 10, name); manager.declare(false); Channel channel = manager.getChannel(); channel.exchangeDeclare(exchange, BuiltinExchangeType.FANOUT); channel.queueBind(manager.getQueueName(), exchange, StringHelper.EMPTY); return manager; }
Example #23
Source File: AmqpRule.java From james-project with Apache License 2.0 | 5 votes |
@Override protected void before() throws Throwable { amqpUri = "amqp://" + rabbitMqContainer.getContainerIp(); ConnectionFactory factory = new ConnectionFactory(); factory.setUri(amqpUri); waitingForRabbitToBeReady(factory); connection = factory.newConnection(); channel = connection.createChannel(); channel.exchangeDeclare(exchangeName, BuiltinExchangeType.DIRECT); queueName = channel.queueDeclare().getQueue(); channel.queueBind(queueName, exchangeName, routingKey); }
Example #24
Source File: RabbitEventChannel.java From jstarcraft-core with Apache License 2.0 | 5 votes |
public RabbitEventChannel(EventMode mode, String name, Channel channel, ContentCodec codec) { super(mode, name); this.channel = channel; this.codec = codec; this.tags = new ConcurrentHashMap<>(); try { channel.exchangeDeclare(name, BuiltinExchangeType.DIRECT); } catch (Exception exception) { throw new RuntimeException(exception); } }
Example #25
Source File: ChannelPoolListener.java From vlingo-examples with Mozilla Public License 2.0 | 5 votes |
@Override public void initialize(final Channel channel) throws IOException { mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); channel.exchangeDeclare("order", BuiltinExchangeType.DIRECT, true); channel.queueDeclare("registered-order", true, false, false, null); channel.queueBind("registered-order", "order", "registered-order"); }
Example #26
Source File: ExchangeTest.java From rabbitmq-mock with Apache License 2.0 | 5 votes |
@ParameterizedTest(name = "{0} matching all headers '{'os: 'linux', cores: '8''}': {1}") @CsvSource({ "'', false", "'os, linux', false", "'os, linux, cores, 4', false", "'os, linux, cores, 8', true", }) void headers_topic_with_x_match_all_does_not_match_if_one_header_is_not_matching(String headers, boolean matches) { MultipleReceiverExchange headersExchange = (MultipleReceiverExchange) mockExchangeFactory.build("test", BuiltinExchangeType.HEADERS.getType(), empty(), mock(ReceiverRegistry.class)); BindConfiguration bindConfiguration = new BindConfiguration("unused", null, map("os", "linux", "cores", "8", "x-match", "all")); assertThat(headersExchange.match(bindConfiguration, "unused", map(headers.split(",\\s*")))).isEqualTo(matches); }
Example #27
Source File: ExchangeTest.java From rabbitmq-mock with Apache License 2.0 | 5 votes |
@ParameterizedTest(name = "{1} does not match {0} as topic bindingKey") @CsvSource({ "some.key, other.key", "*.orange.*, lazy.pink.rabbit", "*.orange.*, quick.orange.male.rabbit", "*.*.rabbit, quick.orange.fox", "*.*.rabbit, quick.orange.male.rabbit", "lazy.#, quick.brown.fox" }) void binding_key_does_not_match_routing_key(String bindingKey, String routingKey) { MultipleReceiverExchange topicExchange = (MultipleReceiverExchange) mockExchangeFactory.build("test", BuiltinExchangeType.TOPIC.getType(), empty(), mock(ReceiverRegistry.class)); BindConfiguration bindConfiguration = new BindConfiguration(bindingKey, null, emptyMap()); assertThat(topicExchange.match(bindConfiguration, routingKey, emptyMap())).isFalse(); }
Example #28
Source File: ChannelTest.java From rabbitmq-mock with Apache License 2.0 | 5 votes |
@Test void exchangeDeclareNoWait_creates_it() throws IOException, TimeoutException { try (Connection conn = new MockConnectionFactory().newConnection()) { try (Channel channel = conn.createChannel()) { channel.exchangeDeclareNoWait("test1", BuiltinExchangeType.DIRECT, true, false, false, null); assertThat(channel.exchangeDeclarePassive("test1")).isNotNull(); } } }
Example #29
Source File: ChannelTest.java From rabbitmq-mock with Apache License 2.0 | 5 votes |
@Test void exchangeDelete_removes_it() throws IOException, TimeoutException { try (Connection conn = new MockConnectionFactory().newConnection()) { try (Channel channel = conn.createChannel()) { channel.exchangeDeclareNoWait("test1", BuiltinExchangeType.DIRECT, true, false, false, null); assertThat(channel.exchangeDelete("test1")).isNotNull(); assertThatExceptionOfType(IOException.class) .isThrownBy(() -> channel.exchangeDeclarePassive("test1")); } } }
Example #30
Source File: ChannelTest.java From rabbitmq-mock with Apache License 2.0 | 5 votes |
@Test void exchangeDeleteNoWait_removes_it() throws IOException, TimeoutException { try (Connection conn = new MockConnectionFactory().newConnection()) { try (Channel channel = conn.createChannel()) { channel.exchangeDeclareNoWait("test1", BuiltinExchangeType.DIRECT, true, false, false, null); channel.exchangeDeleteNoWait("test1", false); assertThatExceptionOfType(IOException.class) .isThrownBy(() -> channel.exchangeDeclarePassive("test1")); } } }