+/*-
+ * ============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.MRClient.MRApiException;
import com.att.nsa.mr.client.impl.MRConsumerImpl;
import com.att.nsa.mr.test.clients.ProtocolTypeConstants;
* fetch messages
*
* @return list of messages
- * @throws Exception when error encountered by underlying libraries
+ * @throws MRApiException when error encountered by underlying libraries
*/
- public Iterable<String> fetch() throws Exception;
+ public Iterable<String> fetch() throws MRApiException;
/**
* close underlying library consumer
public DmaapConsumerWrapper(List<String> 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,
/**
* {@inheritDoc}
*/
- public Iterable<String> fetch() throws Exception {
- return this.consumer.fetch();
+ @Override
+ public Iterable<String> 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();
}