Search in sources :

Example 1 with TypedProperties

use of org.apache.activemq.artemis.utils.collections.TypedProperties in project activemq-artemis by apache.

the class DiscoveryGroup method stop.

@Override
public void stop() {
    synchronized (this) {
        if (!started) {
            return;
        }
        started = false;
    }
    synchronized (waitLock) {
        waitLock.notifyAll();
    }
    try {
        endpoint.close(false);
    } catch (Exception e1) {
        ActiveMQClientLogger.LOGGER.errorStoppingDiscoveryBroadcastEndpoint(endpoint, e1);
    }
    try {
        if (thread != null) {
            thread.interrupt();
            thread.join(10000);
            if (thread.isAlive()) {
                ActiveMQClientLogger.LOGGER.timedOutStoppingDiscovery();
            }
        }
    } catch (InterruptedException e) {
        throw new ActiveMQInterruptedException(e);
    }
    thread = null;
    if (notificationService != null) {
        TypedProperties props = new TypedProperties();
        props.putSimpleStringProperty(new SimpleString("name"), new SimpleString(name));
        Notification notification = new Notification(nodeID, CoreNotificationType.DISCOVERY_GROUP_STOPPED, props);
        try {
            notificationService.sendNotification(notification);
        } catch (Exception e) {
            ActiveMQClientLogger.LOGGER.errorSendingNotifOnDiscoveryStop(e);
        }
    }
}
Also used : ActiveMQInterruptedException(org.apache.activemq.artemis.api.core.ActiveMQInterruptedException) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) ActiveMQInterruptedException(org.apache.activemq.artemis.api.core.ActiveMQInterruptedException) ActiveMQInterruptedException(org.apache.activemq.artemis.api.core.ActiveMQInterruptedException) Notification(org.apache.activemq.artemis.core.server.management.Notification)

Example 2 with TypedProperties

use of org.apache.activemq.artemis.utils.collections.TypedProperties in project activemq-artemis by apache.

the class TypedPropertiesConversionTest method setUp.

// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Before
public void setUp() throws Exception {
    key = RandomUtil.randomSimpleString();
    props = new TypedProperties();
}
Also used : TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) Before(org.junit.Before)

Example 3 with TypedProperties

use of org.apache.activemq.artemis.utils.collections.TypedProperties in project activemq-artemis by apache.

the class PostOfficeImpl method removeBinding.

@Override
public synchronized Binding removeBinding(final SimpleString uniqueName, Transaction tx, boolean deleteData) throws Exception {
    if (server.hasBrokerPlugins()) {
        server.callBrokerPlugins(plugin -> plugin.beforeRemoveBinding(uniqueName, tx, deleteData));
    }
    addressSettingsRepository.clearCache();
    Binding binding = addressManager.removeBinding(uniqueName, tx);
    if (binding == null) {
        throw new ActiveMQNonExistentQueueException();
    }
    if (deleteData && addressManager.getBindingsForRoutingAddress(binding.getAddress()) == null) {
        pagingManager.deletePageStore(binding.getAddress());
        deleteDuplicateCache(binding.getAddress());
    }
    if (binding.getType() == BindingType.LOCAL_QUEUE) {
        Queue queue = (Queue) binding.getBindable();
        managementService.unregisterQueue(uniqueName, binding.getAddress(), queue.getRoutingType());
    } else if (binding.getType() == BindingType.DIVERT) {
        managementService.unregisterDivert(uniqueName, binding.getAddress());
    }
    if (binding.getType() != BindingType.DIVERT) {
        TypedProperties props = new TypedProperties();
        props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress());
        props.putSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME, binding.getClusterName());
        props.putSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName());
        props.putIntProperty(ManagementHelper.HDR_DISTANCE, binding.getDistance());
        props.putLongProperty(ManagementHelper.HDR_BINDING_ID, binding.getID());
        if (binding.getFilter() == null) {
            props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, null);
        } else {
            props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, binding.getFilter().getFilterString());
        }
        managementService.sendNotification(new Notification(null, CoreNotificationType.BINDING_REMOVED, props));
    }
    binding.close();
    if (server.hasBrokerPlugins()) {
        server.callBrokerPlugins(plugin -> plugin.afterRemoveBinding(binding, tx, deleteData));
    }
    return binding;
}
Also used : Binding(org.apache.activemq.artemis.core.postoffice.Binding) QueueBinding(org.apache.activemq.artemis.core.postoffice.QueueBinding) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException) TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) Queue(org.apache.activemq.artemis.core.server.Queue) Notification(org.apache.activemq.artemis.core.server.management.Notification)

Example 4 with TypedProperties

use of org.apache.activemq.artemis.utils.collections.TypedProperties in project activemq-artemis by apache.

the class PostOfficeImpl method addBinding.

// TODO - needs to be synchronized to prevent happening concurrently with activate()
// (and possible removeBinding and other methods)
// Otherwise can have situation where createQueue comes in before failover, then failover occurs
// and post office is activated but queue remains unactivated after failover so delivery never occurs
// even though failover is complete
@Override
public synchronized void addBinding(final Binding binding) throws Exception {
    if (server.hasBrokerPlugins()) {
        server.callBrokerPlugins(plugin -> plugin.beforeAddBinding(binding));
    }
    addressManager.addBinding(binding);
    TypedProperties props = new TypedProperties();
    props.putIntProperty(ManagementHelper.HDR_BINDING_TYPE, binding.getType().toInt());
    props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress());
    props.putSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME, binding.getClusterName());
    props.putSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName());
    props.putLongProperty(ManagementHelper.HDR_BINDING_ID, binding.getID());
    props.putIntProperty(ManagementHelper.HDR_DISTANCE, binding.getDistance());
    Filter filter = binding.getFilter();
    if (filter != null) {
        props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, filter.getFilterString());
    }
    String uid = UUIDGenerator.getInstance().generateStringUUID();
    if (logger.isDebugEnabled()) {
        logger.debug("ClusterCommunication::Sending notification for addBinding " + binding + " from server " + server);
    }
    managementService.sendNotification(new Notification(uid, CoreNotificationType.BINDING_ADDED, props));
    if (server.hasBrokerPlugins()) {
        server.callBrokerPlugins(plugin -> plugin.afterAddBinding(binding));
    }
}
Also used : Filter(org.apache.activemq.artemis.core.filter.Filter) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) Notification(org.apache.activemq.artemis.core.server.management.Notification)

Example 5 with TypedProperties

use of org.apache.activemq.artemis.utils.collections.TypedProperties in project activemq-artemis by apache.

the class MapMessageUtil method readBodyMap.

/**
 * Utility method to set the map on a message body
 */
public static TypedProperties readBodyMap(ActiveMQBuffer message) {
    TypedProperties map = new TypedProperties();
    readBodyMap(message, map);
    return map;
}
Also used : TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties)

Aggregations

TypedProperties (org.apache.activemq.artemis.utils.collections.TypedProperties)43 Notification (org.apache.activemq.artemis.core.server.management.Notification)24 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)23 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)8 Test (org.junit.Test)5 ActiveMQInterruptedException (org.apache.activemq.artemis.api.core.ActiveMQInterruptedException)3 ByteBuf (io.netty.buffer.ByteBuf)2 Channel (io.netty.channel.Channel)2 ServerChannel (io.netty.channel.ServerChannel)2 EpollServerSocketChannel (io.netty.channel.epoll.EpollServerSocketChannel)2 KQueueServerSocketChannel (io.netty.channel.kqueue.KQueueServerSocketChannel)2 LocalServerChannel (io.netty.channel.local.LocalServerChannel)2 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)2 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)2 ActiveMQIllegalStateException (org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException)2 ActiveMQNonExistentQueueException (org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException)2 ClusterConnection (org.apache.activemq.artemis.core.server.cluster.ClusterConnection)2 Connection (org.apache.activemq.artemis.spi.core.remoting.Connection)2 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)1 ChannelInitializer (io.netty.channel.ChannelInitializer)1