throw new RuntimeException(e);
}
}
public SubscribeResponseDocument Subscribe(SubscribeDocument requestDoc) {
Subscribe subscribe = requestDoc.getSubscribe();
Calendar terminationTime = subscribe.getInitialTerminationTime();
if( terminationTime!=null ) {
// Termination time cannot be in the past
if( terminationTime.before( Calendar.getInstance() ) ) {
// Is this the right way to fault??
throw new RuntimeException("Termination time cannot be in the past.");
}
// We could fault here if the time is too far in the future.
} else {
// We could default a sensible timeout here.
}
ActiveMQSubscription subscription;
try {
subscription = new ActiveMQSubscription(connection);
subscription.setTopicExpression(subscribe.getTopicExpression());
subscription.setConsumerReference(subscribe.getConsumerReference());
subscription.setPrecondition(subscribe.getPrecondition());
subscription.setSelector(subscribe.getSelector());
subscription.setSubscriptionPolicy(subscribe.getSubscriptionPolicy());
subscription.setTopicExpression(subscribe.getTopicExpression());
subscription.setUseNotify(subscribe.getUseNotify());
subscription.setConsumer( createNotificationConsumer(subscribe.getConsumerReference()) );
subscription.start();
} catch (JMSException e) {
throw new RuntimeException(e);