/** * Copyright (c) 2012 - 2017 Data In Motion and others. * All rights reserved. * * This program and the accompanying materials are made available under the terms of the * Eclipse Public License v1.0 which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Data In Motion - initial API and implementation */ package org.gecko.osgi.messaging; import java.nio.ByteBuffer; import org.osgi.annotation.versioning.ProviderType; import org.osgi.util.pushstream.PushStream; /** * Messaging service interface to handle message related configurations * @author Mark Hoffmann * @since 10.10.2017 */ @ProviderType public interface MessagingService extends MessagingConstants { /** * Subscribe the {@link PushStream} to the given topic * @param topic the MQTT topic to subscribe * @return a {@link PushStream} instance for the given topic * @throws Exception thrown on errors */ public PushStream subscribe(String topic) throws Exception; /** * Subscribe the {@link PushStream} to the given topic with a certain quality of service * @param topic the message topic to subscribe * @param context the optional properties in the context * @return a {@link PushStream} instance for the given topic * @throws Exception thrown on errors */ public PushStream subscribe(String topic, MessagingContext context) throws Exception; public void publish(String topic, ByteBuffer content) throws Exception; public void publish(String topic, ByteBuffer content, MessagingContext context) throws Exception; }