X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=PolicyEngineUtils%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Futils%2FBusConsumer.java;h=0d4c86b3d9b738b022ec60d4f06a603a232f63ec;hb=677d872505a8b74a175023ff199b123ff2147dc8;hp=bf92835c6a76ddaf6fcebec57077239a353c79b8;hpb=073cc188efe9abb4c010cf674e34e2cf46ef1c52;p=policy%2Fengine.git diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BusConsumer.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BusConsumer.java index bf92835c6..0d4c86b3d 100644 --- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BusConsumer.java +++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/BusConsumer.java @@ -1,10 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineUtils + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.onap.policy.utils; +import java.net.MalformedURLException; import java.util.List; import java.util.Properties; - -import com.att.nsa.mr.client.impl.MRConsumerImpl; -import com.att.nsa.mr.test.clients.ProtocolTypeConstants; +import org.onap.dmaap.mr.client.MRClient.MRApiException; +import org.onap.dmaap.mr.client.impl.MRConsumerImpl; +import org.onap.dmaap.mr.test.clients.ProtocolTypeConstants; public interface BusConsumer { @@ -12,9 +33,9 @@ public interface BusConsumer { * fetch messages * * @return list of messages - * @throws Exception when error encountered by underlying libraries + * @throws MRApiException when error encountered by underlying libraries */ - public Iterable fetch() throws Exception; + public Iterable fetch() throws MRApiException; /** * close underlying library consumer @@ -48,8 +69,7 @@ public interface BusConsumer { public DmaapConsumerWrapper(List servers, String topic, String aafLogin, String aafPassword, String consumerGroup, String consumerInstance, - int fetchTimeout, int fetchLimit) - throws Exception { + int fetchTimeout, int fetchLimit) throws MalformedURLException{ this.consumer = new MRConsumerImpl(servers, topic, consumerGroup, consumerInstance, @@ -70,13 +90,19 @@ public interface BusConsumer { /** * {@inheritDoc} */ - public Iterable fetch() throws Exception { - return this.consumer.fetch(); + @Override + public Iterable fetch() throws MRApiException { + try { + return this.consumer.fetch(); + } catch (Exception e) { + throw new MRApiException("Error during MR consumer Fetch ",e); + } } /** * {@inheritDoc} */ + @Override public void close() { this.consumer.close(); }