InvalidMessageContentExpressionFault, InvalidTopicExpressionFault, UnrecognizedPolicyRequestFault,
UnsupportedPolicyRequestFault, ResourceUnknownFault, NotifyMessageNotSupportedFault,
InvalidProducerPropertiesExpressionFault {
//CHECKSTYLE:ON
Subscribe subscribeRequest = new Subscribe();
subscribeRequest.setConsumerReference(consumer.getEpr());
subscribeRequest.setFilter(new FilterType());
if (topic != null) {
TopicExpressionType topicExp = new TopicExpressionType();
topicExp.getContent().add(topic);
subscribeRequest.getFilter().getAny().add(
new JAXBElement<TopicExpressionType>(QNAME_TOPIC_EXPRESSION,
TopicExpressionType.class, topicExp));
}
if (xpath != null) {
QueryExpressionType xpathExp = new QueryExpressionType();
xpathExp.setDialect(XPATH1_URI);
xpathExp.getContent().add(xpath);
subscribeRequest.getFilter().getAny().add(
new JAXBElement<QueryExpressionType>(QNAME_MESSAGE_CONTENT,
QueryExpressionType.class, xpathExp));
}
if (raw) {
subscribeRequest.setSubscriptionPolicy(new Subscribe.SubscriptionPolicy());
subscribeRequest.getSubscriptionPolicy().getAny().add(new UseRaw());
}
SubscribeResponse response = broker.subscribe(subscribeRequest);
return new Subscription(response.getSubscriptionReference());
}