Java Code Examples for org.springframework.cloud.stream.binder.ConsumerProperties#setMultiplex()
The following examples show how to use
org.springframework.cloud.stream.binder.ConsumerProperties#setMultiplex() .
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: GlobalKTableBoundElementFactory.java From spring-cloud-stream-binder-kafka with Apache License 2.0 | 8 votes |
@Override public GlobalKTable createInput(String name) { BindingProperties bindingProperties = this.bindingServiceProperties.getBindingProperties(name); ConsumerProperties consumerProperties = bindingProperties.getConsumer(); if (consumerProperties == null) { consumerProperties = this.bindingServiceProperties.getConsumerProperties(name); consumerProperties.setUseNativeDecoding(true); } else { if (!encodingDecodingBindAdviceHandler.isDecodingSettingProvided()) { consumerProperties.setUseNativeDecoding(true); } } // Always set multiplex to true in the kafka streams binder consumerProperties.setMultiplex(true); // @checkstyle:off GlobalKTableBoundElementFactory.GlobalKTableWrapperHandler wrapper = new GlobalKTableBoundElementFactory.GlobalKTableWrapperHandler(); // @checkstyle:on ProxyFactory proxyFactory = new ProxyFactory( GlobalKTableBoundElementFactory.GlobalKTableWrapper.class, GlobalKTable.class); proxyFactory.addAdvice(wrapper); return (GlobalKTable) proxyFactory.getProxy(); }
Example 2
Source File: KStreamBoundElementFactory.java From spring-cloud-stream-binder-kafka with Apache License 2.0 | 6 votes |
@Override public KStream createInput(String name) { BindingProperties bindingProperties = this.bindingServiceProperties.getBindingProperties(name); ConsumerProperties consumerProperties = bindingProperties.getConsumer(); if (consumerProperties == null) { consumerProperties = this.bindingServiceProperties.getConsumerProperties(name); consumerProperties.setUseNativeDecoding(true); } else { if (!encodingDecodingBindAdviceHandler.isDecodingSettingProvided()) { consumerProperties.setUseNativeDecoding(true); } } // Always set multiplex to true in the kafka streams binder consumerProperties.setMultiplex(true); return createProxyForKStream(name); }
Example 3
Source File: KTableBoundElementFactory.java From spring-cloud-stream-binder-kafka with Apache License 2.0 | 6 votes |
@Override public KTable createInput(String name) { BindingProperties bindingProperties = this.bindingServiceProperties.getBindingProperties(name); ConsumerProperties consumerProperties = bindingProperties.getConsumer(); if (consumerProperties == null) { consumerProperties = this.bindingServiceProperties.getConsumerProperties(name); consumerProperties.setUseNativeDecoding(true); } else { if (!encodingDecodingBindAdviceHandler.isDecodingSettingProvided()) { consumerProperties.setUseNativeDecoding(true); } } // Always set multiplex to true in the kafka streams binder consumerProperties.setMultiplex(true); KTableBoundElementFactory.KTableWrapperHandler wrapper = new KTableBoundElementFactory.KTableWrapperHandler(); ProxyFactory proxyFactory = new ProxyFactory( KTableBoundElementFactory.KTableWrapper.class, KTable.class); proxyFactory.addAdvice(wrapper); return (KTable) proxyFactory.getProxy(); }
Example 4
Source File: BindingServiceTests.java From spring-cloud-stream with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testConsumerBindingWhenMultiplexingIsEnabled() throws Exception { BindingServiceProperties properties = new BindingServiceProperties(); Map<String, BindingProperties> bindingProperties = new HashMap<>(); BindingProperties props = new BindingProperties(); props.setDestination("foo,bar"); ConsumerProperties consumer = properties.getConsumerProperties("input"); consumer.setMultiplex(true); props.setConsumer(consumer); final String inputChannelName = "input"; bindingProperties.put(inputChannelName, props); properties.setBindings(bindingProperties); DefaultBinderFactory binderFactory = createMockBinderFactory(); Binder binder = binderFactory.getBinder("mock", MessageChannel.class); BindingService service = new BindingService(properties, binderFactory); MessageChannel inputChannel = new DirectChannel(); Binding<MessageChannel> mockBinding1 = Mockito.mock(Binding.class); when(binder.bindConsumer(eq("foo,bar"), isNull(), same(inputChannel), any(ConsumerProperties.class))).thenReturn(mockBinding1); Collection<Binding<MessageChannel>> bindings = service.bindConsumer(inputChannel, "input"); assertThat(bindings).hasSize(1); Iterator<Binding<MessageChannel>> iterator = bindings.iterator(); Binding<MessageChannel> binding1 = iterator.next(); assertThat(binding1).isSameAs(mockBinding1); service.unbindConsumers("input"); verify(binder).bindConsumer(eq("foo,bar"), isNull(), same(inputChannel), any(ConsumerProperties.class)); verify(binding1).unbind(); binderFactory.destroy(); }