SQLFilter служебной шины Azure не работает с использованием Azure Java SDK - PullRequest
0 голосов
/ 10 мая 2019

Я пытаюсь получить только те сообщения, которые удовлетворяют условию, указанному в фильтре, но это не работает. Он просто возвращает все сообщения. Я вижу, как правило применяется в проводнике, но сообщения не фильтруются.

ниже мой фрагмент кода

public class MyServiceBusTopicSubscriber {
  static final Gson GSON = new Gson();

  public static void main(String[] args) throws Exception, ServiceBusException {
    String connectionString = "MyConnectionString";
    SubscriptionClient subscription1Client = new SubscriptionClient(new ConnectionStringBuilder(connectionString, "myTopic"), ReceiveMode.PEEKLOCK);
    // Drop existing rules and add a TrueFilter
    for (RuleDescription rd : subscription1Client.getRulesAsync().get()) {
        subscription1Client.removeRuleAsync(rd.getName());
    }
    RuleDescription ruleDescription = new RuleDescription("FilterEvents");
    ruleDescription.setFilter( new SqlFilter("1!=1"));
    SqlRuleAction action = new SqlRuleAction("set FilterTag = 'true'");
    ruleDescription.setAction(action);
    subscription1Client.addRuleAsync(ruleDescription);
    registerMessageHandlerOnClient(subscription1Client);
}

static void registerMessageHandlerOnClient(SubscriptionClient receiveClient) throws Exception {

    ISessionHandler sessionHandler = new ISessionHandler() {
        @Override
        public CompletableFuture<Void> onMessageAsync(IMessageSession iMessageSession, IMessage message) {
            System.out.println(ToStringBuilder.reflectionToString(message));
            byte[] body = message.getBody();
            String data = new String(Base64.decodeBase64(body), UTF_8);
            Response response = GSON.fromJson(data, Response.class);
            System.err.println(GSON.toJson(response));

            return receiveClient.completeAsync(message.getLockToken());
        }

        @Override
        public CompletableFuture<Void> OnCloseSessionAsync(IMessageSession iMessageSession) {
            return null;
        }

        @Override
        public void notifyException(Throwable throwable, ExceptionPhase exceptionPhase) {

        }
    };
    receiveClient.registerSessionHandler(sessionHandler);
}

}

В библиотеке это записывается как

/**
 * Represents a filter expression that is evaluated against a message on a 
topic. This client library provides support for creating only limited types of filters.
* This is an empty interface to serve as root interface for all supported filter types.
*
* @since 1.0
*/
public abstract class Filter {
 // No methods. Just a skeleton root class for filters
 // Filter execution happens in the cloud on .net runtime. There is no point implementing custom filters in Java.
}

не поддерживает Java? или я что-то не так делаю? указатели будут полезны

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...