|
| 1 | +/** |
| 2 | + * Copyright 2019 The JoyQueue Authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.joyqueue.client.samples.springcloud.stream; |
| 17 | + |
| 18 | +import org.springframework.boot.SpringApplication; |
| 19 | +import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 20 | +import org.springframework.cloud.stream.annotation.EnableBinding; |
| 21 | +import org.springframework.context.ConfigurableApplicationContext; |
| 22 | +import org.springframework.messaging.Message; |
| 23 | +import org.springframework.messaging.support.GenericMessage; |
| 24 | + |
| 25 | +@EnableBinding(CustomProcessor.class) |
| 26 | +@SpringBootApplication(scanBasePackages = {"org.joyqueue.client.samples.springcloud.stream"}) |
| 27 | +public class StreamBootstrap { |
| 28 | + |
| 29 | + public static void main(String[] args) throws InterruptedException { |
| 30 | + System.setProperty("spring.profiles.active", "stream"); |
| 31 | + ConfigurableApplicationContext run = SpringApplication.run(StreamBootstrap.class, args); |
| 32 | + CustomProcessor processor = run.getBean(CustomProcessor.class); |
| 33 | + |
| 34 | + for (int i = 0; i < 100; i++) { |
| 35 | + Message<String> message = new GenericMessage<>("Hello - " + i); |
| 36 | + //Message<String> received = (Message<String>) messageCollector.forChannel(processor.output()).poll(); |
| 37 | + //Assert.assertThat(received.getPayload(), equalTo("hello world")); |
| 38 | + processor.outputOrder().send(message); |
| 39 | + |
| 40 | + Thread.sleep(1000); |
| 41 | + } |
| 42 | + } |
| 43 | +} |
0 commit comments