2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.aai.event;
23 import org.apache.camel.Category;
24 import org.apache.camel.Consumer;
25 import org.apache.camel.Processor;
26 import org.apache.camel.Producer;
27 import org.apache.camel.spi.Metadata;
28 import org.apache.camel.spi.UriEndpoint;
29 import org.apache.camel.spi.UriParam;
30 import org.apache.camel.spi.UriPath;
31 import org.onap.aai.cl.api.Logger;
32 import org.onap.aai.cl.eelf.LoggerFactory;
33 import org.onap.aai.event.api.EventConsumer;
34 import org.onap.aai.event.api.EventPublisher;
36 @UriEndpoint(scheme = "event-bus", syntax = "event-bus:name",
37 consumerClass = EventBusConsumer.class, title = "event-bus",
38 firstVersion = "1.0.0", category = {Category.CORE})
39 public class EventBusEndPoint extends AbstractEventBusEndpoint {
41 @UriPath(description = "client name")
43 @UriParam(label = "eventTopic", description = "event topic")
44 @Metadata(required = true)
45 private String eventTopic;
46 @UriParam(label = "poolSize", description = "pool size")
47 @Metadata(required = true, defaultValue="20")
48 private int poolSize = 20;
49 @UriParam(label = "pollingDelay", description = "polling delay")
50 @Metadata(required = true, defaultValue="30000")
51 private int pollingDelay = 30000;
53 EventConsumer consumer; //This would be injected via bean through camel route when passed with #
55 EventPublisher publisher; //This would be injected via bean through camel route when passed with #
57 private Logger logger = LoggerFactory.getInstance().getLogger(EventBusEndPoint.class);
59 public EventBusEndPoint(String uri, EventBusComponent component) {
60 super(uri, component);
64 public Producer createProducer() throws Exception {
65 return new EventBusProducer(this, publisher);
69 public Consumer createConsumer(Processor processor) throws Exception {
70 return new EventBusConsumer(this, processor, consumer);
74 public boolean isSingleton() {
78 void end() throws Exception {
85 public void setPoolSize(int poolSize) {
86 this.poolSize = poolSize;
89 public void setPollingDelay(int pollingDelay) {
90 this.pollingDelay = pollingDelay;
93 public int getPollingDelay() {
96 public int getPoolSize() {
99 public String getEventTopic() {
103 public String getName() {
107 public void setName(String name) {
111 public void setEventTopic(String eventTopic) {
112 this.eventTopic = eventTopic;
115 public void setConsumer(EventConsumer consumer) {
116 this.consumer = consumer;
119 public void setPublisher(EventPublisher publisher) {
120 this.publisher = publisher;