alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

ActiveMQ example source code file (InactiveDurableSubscriptionView.java)

This example ActiveMQ source code file (InactiveDurableSubscriptionView.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - ActiveMQ tags/keywords

compositedata, connectioncontext, durablesubscriptionview, durablesubscriptionviewmbean, inactivedurablesubscriptionview, inactivedurablesubscriptionview, opendataexception, opendataexception, removesubscriptioninfo, removesubscriptioninfo, string, string, subscriptioninfo, tabulardata

The ActiveMQ InactiveDurableSubscriptionView.java source code

/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.activemq.broker.jmx;

import javax.management.openmbean.CompositeData;
import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.TabularData;

import org.apache.activemq.broker.ConnectionContext;
import org.apache.activemq.command.RemoveSubscriptionInfo;
import org.apache.activemq.command.SubscriptionInfo;

/**
 * 
 * 
 */
public class InactiveDurableSubscriptionView extends DurableSubscriptionView implements DurableSubscriptionViewMBean {
    protected SubscriptionInfo subscriptionInfo;

    /**
     * Constructor
     * 
     * @param broker
     * @param clientId
     * @param sub
     */
    public InactiveDurableSubscriptionView(ManagedRegionBroker broker, String clientId, SubscriptionInfo sub) {
        super(broker,clientId, null);
        this.broker = broker;
        this.subscriptionInfo = sub;
    }

    /**
     * @return the id of the Subscription
     */
    public long getSubcriptionId() {
        return -1;
    }

    /**
     * @return the destination name
     */
    public String getDestinationName() {
        return subscriptionInfo.getDestination().getPhysicalName();

    }

    /**
     * @return true if the destination is a Queue
     */
    public boolean isDestinationQueue() {
        return false;
    }

    /**
     * @return true of the destination is a Topic
     */
    public boolean isDestinationTopic() {
        return true;
    }

    /**
     * @return true if the destination is temporary
     */
    public boolean isDestinationTemporary() {
        return false;
    }

    /**
     * @return name of the durable consumer
     */
    public String getSubscriptionName() {
        return subscriptionInfo.getSubscriptionName();
    }

    /**
     * @return true if the subscriber is active
     */
    public boolean isActive() {
        return false;
    }

    /**
     * Browse messages for this durable subscriber
     * 
     * @return messages
     * @throws OpenDataException
     */
    public CompositeData[] browse() throws OpenDataException {
        return broker.browse(this);
    }

    /**
     * Browse messages for this durable subscriber
     * 
     * @return messages
     * @throws OpenDataException
     */
    public TabularData browseAsTable() throws OpenDataException {
        return broker.browseAsTable(this);
    }

    /**
     * Destroys the durable subscription so that messages will no longer be
     * stored for this subscription
     */
    public void destroy() throws Exception {
        RemoveSubscriptionInfo info = new RemoveSubscriptionInfo();
        info.setClientId(clientId);
        info.setSubscriptionName(subscriptionInfo.getSubscriptionName());
        ConnectionContext context = new ConnectionContext();
        context.setBroker(broker);
        context.setClientId(clientId);
        broker.removeSubscription(context, info);
    }

    public String toString() {
        return "InactiveDurableSubscriptionView: " + getClientId() + ":" + getSubscriptionName();
    }
}

Other ActiveMQ examples (source code examples)

Here is a short list of links related to this ActiveMQ InactiveDurableSubscriptionView.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.