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.Consumer;
24 import org.apache.camel.Processor;
25 import org.apache.camel.Producer;
26 import org.apache.camel.spi.Metadata;
27 import org.apache.camel.spi.UriEndpoint;
28 import org.apache.camel.spi.UriParam;
29 import org.onap.aai.cl.api.Logger;
30 import org.onap.aai.cl.eelf.LoggerFactory;
31 import org.onap.aai.event.api.EventConsumer;
32 import org.onap.aai.event.api.EventPublisher;
34 @UriEndpoint(scheme = "event-bus", syntax = "event-bus:name",
35 consumerClass = EventBusConsumer.class, title = "event-bus")
36 public class EventBusEndPoint extends AbstractEventBusEndpoint {
37 @UriParam(label = "eventTopic")
38 @Metadata(required = "true")
39 private String eventTopic;
40 @UriParam(label = "poolSize")
41 @Metadata(required = "true", defaultValue="20")
42 private int poolSize = 20;
43 @UriParam(label = "pollingDelay")
44 @Metadata(required = "true", defaultValue="30000")
45 private int pollingDelay = 30000;
47 EventConsumer consumer; //This would be injected via bean through camel route when passed with #
49 EventPublisher publisher; //This would be injected via bean through camel route when passed with #
51 private Logger logger = LoggerFactory.getInstance().getLogger(EventBusEndPoint.class);
53 public EventBusEndPoint(String uri, EventBusComponent component) {
54 super(uri, component);
58 public Producer createProducer() throws Exception {
59 return new EventBusProducer(this, publisher);
63 public Consumer createConsumer(Processor processor) throws Exception {
64 return new EventBusConsumer(this, processor, consumer);
68 public boolean isSingleton() {
72 void close() throws Exception {
79 public void setPoolSize(int poolSize) {
80 this.poolSize = poolSize;
83 public void setPollingDelay(int pollingDelay) {
84 this.pollingDelay = pollingDelay;
87 public int getPollingDelay() {
90 public int getPoolSize() {
93 public String getEventTopic() {
97 public void setEventTopic(String eventTopic) {
98 this.eventTopic = eventTopic;
101 public void setConsumer(EventConsumer consumer) {
102 this.consumer = consumer;
105 public void setPublisher(EventPublisher publisher) {
106 this.publisher = publisher;