// START SNIPPET: subscribe
SubscribeDocument subrequest = SubscribeDocument.Factory.newInstance();
SubscribeDocument.Subscribe subscribe = subrequest.addNewSubscribe();
subscribe.setTopicExpression( TopicExpressionConverter.toTopicExpression(topic) );
subscribe.setUseNotify(true);
SubscribeResponseDocument subresponse = broker.Subscribe(subrequest);
// END SNIPPET: subscribe
System.out.println("Sub request: "+subrequest);
System.out.println("Sub response: "+subresponse);
assertNotNull(subresponse);
return subresponse.getSubscribeResponse().getSubscriptionReference();
}