Search in sources :

Example 1 with UnableToDestroySubscriptionFault

use of org.oasis_open.docs.wsn.bw_2.UnableToDestroySubscriptionFault in project cxf by apache.

the class AbstractNotificationBroker method handleSubscribe.

public SubscribeResponse handleSubscribe(Subscribe subscribeRequest, EndpointManager manager) throws // CHECKSTYLE:OFF - WS-Notification spec throws a lot of faults
InvalidFilterFault, InvalidMessageContentExpressionFault, InvalidProducerPropertiesExpressionFault, InvalidTopicExpressionFault, SubscribeCreationFailedFault, TopicExpressionDialectUnknownFault, TopicNotSupportedFault, UnacceptableInitialTerminationTimeFault, UnsupportedPolicyRequestFault, UnrecognizedPolicyRequestFault {
    // CHECKSTYLE:ON
    AbstractSubscription subscription = null;
    boolean success = false;
    try {
        subscription = createSubscription(idGenerator.generateSanitizedId());
        subscription.setBroker(this);
        subscriptions.put(subscription.getAddress(), subscription);
        subscription.create(subscribeRequest);
        if (manager != null) {
            subscription.setManager(manager);
        }
        subscription.register();
        SubscribeResponse response = new SubscribeResponse();
        response.setSubscriptionReference(subscription.getEpr());
        success = true;
        return response;
    } catch (EndpointRegistrationException e) {
        LOGGER.log(Level.WARNING, "Unable to register new endpoint", e);
        SubscribeCreationFailedFaultType fault = new SubscribeCreationFailedFaultType();
        throw new SubscribeCreationFailedFault("Unable to register new endpoint", fault, e);
    } finally {
        if (!success && subscription != null) {
            if (subscription.getAddress() != null) {
                subscriptions.remove(subscription.getAddress());
            }
            try {
                subscription.unsubscribe();
            } catch (UnableToDestroySubscriptionFault e) {
                LOGGER.log(Level.INFO, "Error destroying subscription", e);
            }
        }
    }
}
Also used : SubscribeCreationFailedFault(org.oasis_open.docs.wsn.bw_2.SubscribeCreationFailedFault) UnableToDestroySubscriptionFault(org.oasis_open.docs.wsn.bw_2.UnableToDestroySubscriptionFault) SubscribeCreationFailedFaultType(org.oasis_open.docs.wsn.b_2.SubscribeCreationFailedFaultType) SubscribeResponse(org.oasis_open.docs.wsn.b_2.SubscribeResponse)

Example 2 with UnableToDestroySubscriptionFault

use of org.oasis_open.docs.wsn.bw_2.UnableToDestroySubscriptionFault in project cxf by apache.

the class JmsSubscription method unsubscribe.

@Override
protected void unsubscribe() throws UnableToDestroySubscriptionFault {
    super.unsubscribe();
    if (session != null) {
        try {
            session.close();
            checkTermination = false;
        } catch (JMSException e) {
            UnableToDestroySubscriptionFaultType fault = new UnableToDestroySubscriptionFaultType();
            throw new UnableToDestroySubscriptionFault("Unable to unsubscribe", fault, e);
        } finally {
            session = null;
        }
    }
}
Also used : UnableToDestroySubscriptionFaultType(org.oasis_open.docs.wsn.b_2.UnableToDestroySubscriptionFaultType) UnableToDestroySubscriptionFault(org.oasis_open.docs.wsn.bw_2.UnableToDestroySubscriptionFault) JMSException(javax.jms.JMSException)

Aggregations

UnableToDestroySubscriptionFault (org.oasis_open.docs.wsn.bw_2.UnableToDestroySubscriptionFault)2 JMSException (javax.jms.JMSException)1 SubscribeCreationFailedFaultType (org.oasis_open.docs.wsn.b_2.SubscribeCreationFailedFaultType)1 SubscribeResponse (org.oasis_open.docs.wsn.b_2.SubscribeResponse)1 UnableToDestroySubscriptionFaultType (org.oasis_open.docs.wsn.b_2.UnableToDestroySubscriptionFaultType)1 SubscribeCreationFailedFault (org.oasis_open.docs.wsn.bw_2.SubscribeCreationFailedFault)1